Sessions
tmux new -s <name>
New named session
Without -s the session is just numbered 0, 1, 2 ...
tmux a -t <name>
Attach to session
tmux a on its own attaches to the most recent session.
prefix
d
Detach from session
Programs inside keep running; reattach any time.
prefix
s
Choose session from list
Shows a live preview of each window; Enter switches.
tmux kill-session -t <name>
Kill session
tmux new -As <name>
Attach, or create if missing
Ideal for shell aliases: attaches if the session exists.
prefix
(
/
)
Previous / next session
tmux a -d -t <name>
Attach and detach other clients
tmux kill-server
Kill all sessions
Also kills every program running inside.
Panes
prefix
%
Split left / right
Mnemonic: % looks like two panes side by side.
prefix
"
Split top / bottom
Mnemonic: the two dots are stacked, one above the other.
prefix
Arrows
Move between panes
prefix
z
Zoom pane (toggle)
A Z appears in the status bar while zoomed; press again to
restore.
prefix
x
Close pane
Asks for confirmation (y/n) first.
prefix
o
Cycle to next pane
prefix
!
Break pane into own window
Undo it with join-pane -s <window>.
prefix
Ctrl+Arrow
Resize pane (hold)
Repeat within about half a second without pressing the prefix
again.
prefix
Space
Cycle pane layouts
Cycles even-horizontal, even-vertical, main-horizontal,
main-vertical, tiled (3.5+ adds mirrored main layouts).
prefix
q
Show pane numbers
prefix
{
/
}
Swap pane with prev / next
Command Mode
prefix
:
Open command prompt
The same commands as the tmux CLI, without the leading tmux.
set -g mouse on
Enable mouse support
On by default since 3.8. Click panes, drag borders, scroll;
hold Shift (Option on macOS) to select text natively.
source ~/.tmux.conf
Reload configuration
Or ~/.config/tmux/tmux.conf if you use the XDG location.
setw synchronize-panes
Type into all panes at once
Run again to switch off; handy for several servers at once.
list-keys
Show all key bindings
set -g history-limit 50000
Longer scrollback
Only affects windows created afterwards; set it in .tmux.conf.
capture-pane -p
Print pane contents to stdout
Add -S - to include the full scrollback.
send-keys -t <pane> "cmd" Enter
Run a command in another pane
Great for starting dev servers in a prepared layout.
swap-window -t <n>
Swap with window n
move-window -r
Renumber windows