Prefix key: Ctrl-b (referred to as C-b below)
tmux # New unnamed session
tmux new -s farm # New session named "farm"
tmux a # Attach to last session
tmux a -t farm # Attach to session named "farm"
tmux kill-session -t farm # Kill session
tmux kill-server # Kill everything
| Keys |
Action |
C-b d |
Detach from session |
C-b $ |
Rename session |
C-b s |
List/switch sessions |
C-b ( |
Previous session |
C-b ) |
Next session |
| Keys |
Action |
C-b c |
New window |
C-b , |
Rename window |
C-b & |
Kill window |
C-b w |
List windows (interactive picker) |
C-b n |
Next window |
C-b p |
Previous window |
C-b 0-9 |
Jump to window by number |
C-b l |
Last active window |
| Keys |
Action |
C-b % |
Split vertical (left/right) |
C-b " |
Split horizontal (top/bottom) |
C-b x |
Kill pane |
C-b o |
Cycle to next pane |
C-b ; |
Toggle to last active pane |
C-b q |
Show pane numbers, then press number to jump |
C-b z |
Zoom/unzoom pane (fullscreen toggle) |
C-b { |
Move pane left |
C-b } |
Move pane right |
C-b Space |
Cycle pane layouts |
C-b ! |
Convert pane to its own window |
| Keys |
Action |
C-b C-arrow |
Resize by 1 cell |
C-b M-arrow |
Resize by 5 cells |
| Keys |
Action |
C-b [ |
Enter copy/scroll mode |
q |
Exit copy mode |
Space |
Start selection (in copy mode) |
Enter |
Copy selection and exit |
C-b ] |
Paste buffer |
/ |
Search forward (in copy mode) |
? |
Search backward (in copy mode) |
g |
Jump to top |
G |
Jump to bottom |
Arrow keys and Page Up/Down work in copy mode.
# Start session, kick off process, detach
tmux new -s deploy -d 'cd ~/projects/bodmail && npm run build'
# Create a session with named windows
tmux new -s farm -n logs -d
tmux new-window -t farm -n build
tmux new-window -t farm -n monitor
# Send commands to specific windows
tmux send-keys -t farm:logs 'tail -f /var/log/app.log' Enter
tmux send-keys -t farm:build 'npm run build' Enter
tmux send-keys -t farm:monitor 'htop' Enter
tmux send-keys -t farm:0 'npm test' Enter
# Run in a pane and get notified
tmux set -t farm monitor-activity on
# Now switch to another window — tmux highlights the window when activity occurs
tmux capture-pane -t farm:0 -p > output.txt # Current visible
tmux capture-pane -t farm:0 -p -S -1000 > output.txt # Last 1000 lines
# Mouse support (scrolling, clicking panes, resizing)
# Increase scrollback buffer
tmux set -g history-limit 50000
# Start window numbering at 1
tmux set -g pane-base-index 1
Put these in ~/.tmux.conf to make them permanent.
C-b d → detach (go do other stuff, come back later)
C-b % → split side by side
C-b z → zoom a pane to fullscreen (again to unzoom)
C-b [ → scroll up through output
C-b w → visual window/session picker