Cheat sheet · No. XIII

tmux.

tmux is a window manager for terminals: a server holds sessions, sessions hold windows, windows hold panes. Detach and the server keeps everything running without you.

Printable One A4 page
PLATE — tmuxFIG. XIII $ vim$ make test$ tail -f log[0] 1:code* 2:ops session: work C-b % split · C-b z zoom · C-b d detachone page, pinned to the wall.
The reference
SESSIONS
tmux new -s work
New named session
tmux new -As work
Attach if it exists, create if not
tmux ls
List sessions
tmux attach -t work
Reattach
tmux kill-session -t work
End one session
tmux kill-server
End everything
WINDOWS (PREFIX = C-b)
c
New window
,
Rename window
n p
Next / previous
0–9
Jump to window by number
w
Pick from a list
&
Kill window (confirms)
PANES
%
Split left/right
"
Split top/bottom
←↑↓→
Move between panes
z
Zoom pane full-screen (toggle)
{ }
Swap pane with previous / next
q
Show pane numbers (press one to jump)
x
Kill pane (confirms)
COPY MODE
[
Enter copy mode (scroll back)
Space
Start selection (v with vi keys)
Enter
Copy selection (y with vi keys)
]
Paste
/
Search forward in scrollback (vi keys)
q
Leave copy mode
WORKFLOWS
d
Detach — session keeps running
s
Switch session from a list
$
Rename session
:
Command prompt (any tmux command)
C-←↑↓→
Resize current pane
ssh box -t tmux new -As main
SSH straight into a session
~/.TMUX.CONF
set -g mouse on
set -g base-index 1
set -g history-limit 50000
setw -g mode-keys vi

# move prefix to C-a
unbind C-b
set -g prefix C-a

# reload config
bind r source-file ~/.tmux.conf
Field notes
Detach, never exit

Closing the terminal kills nothing — the tmux server keeps the session alive. Detach with prefix d and reattach after the network hiccup.

new -As is idempotent

tmux new -As main attaches if the session exists and creates it if not. Perfect as the one-liner you run on every remote box.

Prefix, then key

Press C-b, release it, then the binding. Holding both down at once is the most common beginner stumble.

Zoom beats resizing

prefix z makes the current pane full-screen and toggles back. Far faster than nudging pane borders for a quick close look at output.

Tip: hit ⌘P / Ctrl-P to save this single page as a PDF or print it for the wall.

Found this useful?