Skip to main content

Multi-Session Patterns

Running multiple sessions lets you separate concerns cleanly: development, monitoring, deployment each live in their own named workspace.

Learning Focus

Design your sessions around context, not just habits. A good session naming convention reduces cognitive overhead during incidents.

When to Use Multiple Sessions

SituationSession Design
Ongoing developmentwork, staging, prod
Server maintenanceadmin, logs, monitoring
Deploymentdeploy, rollback, verify
Long-running jobsbuild, migrate, export

Development Server

Session: work
Window 0: editor → vim / nano / code-server
Window 1: server → npm run dev / python manage.py runserver
Window 2: git → git status, pull, push

Monitoring

Session: monitoring
Window 0: sysmon → htop | panes: top-left, top-right
Window 1: logs → tail -f app.log | panes: multiple log files

Deployment

Session: deploy
Window 0: deploy → deployment script running
Window 1: rollback → rollback script ready (not yet run)
Window 2: verify → health check commands

Creating a Multi-Session Setup

multi-session-setup.sh
#!/bin/bash
# Start development sessions

# Session 1: work
tmux new -s work -n editor -d
tmux new-window -t work -n server
tmux new-window -t work -n git

# Session 2: monitoring
tmux new -s monitoring -n sysmon -d
tmux send-keys -t monitoring:sysmon "htop" Enter

# Session 3: logs
tmux new -s logs -n app -d
tmux send-keys -t logs:app "tail -f /var/log/syslog" Enter

echo "Sessions ready. Attach with: tmux attach -t work"
# From inside tmux:
Ctrl+b s → Interactive list of all sessions and windows
Ctrl+b ( → Previous session
Ctrl+b ) → Next session

The Ctrl+b s list is tree-shaped and lets you select any session/window with arrow keys + Enter.

Naming Conventions

PatternExampleBenefit
Environment-basedwork-prod, work-devClear environment context
Task-baseddeploy, migrate, buildTemporary, disposable
Role-basededitor, monitoringPermanent daily-driver sessions
tip

Use short, memorable names. You will type these dozens of times per day. w, m, d are valid session names too.

Switching Sessions in a Script

# Switch to a session from outside tmux
tmux switch-client -t work

# Only works if you are already attached to a tmux session somewhere

Cleaning Up Old Sessions

# List all sessions
tmux ls

# Kill a finished session
tmux kill-session -t deploy

# Kill all sessions except the one you are in
tmux kill-session -a
note

kill-session -a kills all other sessions except the currently attached one.

Common Pitfalls

PitfallWhat happensFix
Too many unnamed sessionsCan't tell which is whichAlways name sessions with -s
Forgetting to clean up finished sessionsClutter and confusionKill session when job is done
Mixing work contexts in one sessionContext switching overheadOne session per concern

What's Next