tmux Cheatsheet
Power user.
Sessions
Sessions are the unit of long-lived work. Create a named session per project, detach when you walk away, and reattach from any new SSH connection. The session keeps running between attaches.
- tmux new -s name Create a named session; one per project keeps work organised across reboots and SSH sessions.
- Ctrl-b d Detach the current session; the session keeps running on the host after SSH drops.
- tmux ls List active sessions on the host; the first command after reconnecting.
- tmux a -t name Attach to a named session; resumes exactly where you left off.
- tmux kill-session -t name Explicit cleanup when you are done with a project; sessions otherwise persist until the host reboots.
Windows
Windows are tabs inside a session. One window per concern, named so the window list reads like a meaningful agenda rather than a numbered grid.
- Ctrl-b c Create a new window inside the session; one per task or service.
- Ctrl-b n / Ctrl-b p Next and previous window; linear walk through the agenda.
- Ctrl-b , Rename the current window; named windows beat numbered ones every time.
- Ctrl-b w Interactive window picker; useful when the window list is long.
- Ctrl-b 0-9 Jump directly to a numbered window; the fastest navigation when you know the index.
Panes
Panes are splits inside a window for adjacent views: logs next to commands, tail next to edit. The right split layout halves the time spent context-switching between terminals.
- Ctrl-b % Vertical split (side-by-side); good for logs alongside commands.
- Ctrl-b " Horizontal split (stacked); good for editor on top, shell below.
- Ctrl-b arrows Move focus between panes; the daily navigation.
- Ctrl-b z Toggle pane zoom (full-screen the current pane); back to the layout with the same key.
- Ctrl-b x Close the current pane; confirm prompt prevents accidents.
- Ctrl-b ! Promote the current pane to its own window; useful when a pane has outgrown its split.
Scrollback and copy
Scrollback is how you read the past inside tmux; copy mode is how you grab a chunk of it without leaving the terminal.
- Ctrl-b [ Enter copy mode; arrows or vim-style keys (with the right config) navigate.
- Space Start a selection in copy mode; visual selection of the region to copy.
- Enter Copy the selection to the tmux buffer; the buffer is paste source for any pane.
- Ctrl-b ] Paste from the current tmux buffer; survives across panes and windows.
- Ctrl-b = Choose from the buffer list; tmux keeps multiple buffers, this is how to pick one.
Config and prefix
The default prefix Ctrl-b is awkward; most operators rebind to Ctrl-a. Keep the rebind and other tweaks in ~/.tmux.conf so every shell inherits the same setup.
- set -g prefix C-a Rebind the prefix to Ctrl-a; the muscle-memory standard.
- set -g mouse on Enable mouse support; modern terminals make this safe and useful.
- set -g history-limit 50000 Larger scrollback than the default; investigations frequently need more than 2000 lines.
- bind r source-file ~/.tmux.conf Live-reload binding; iterate on config without restarting tmux.