Tmux#
Terminal multiplexer. Default prefix is Ctrl-b; many
operators rebind to Ctrl-a (the GNU Screen convention). In
the tables below prefix stands for whichever you’ve bound;
prefix <key> means “send the prefix, release, then press
<key>”. Without the prefix, keystrokes go straight to the
foreground program inside the pane.
tmux list-keys (tmux lsk) prints every active binding
for the current key-table; prefix ? shows the same list in
a pager inside tmux. Copy mode has its own key-table:
tmux list-keys -T copy-mode-vi or -T copy-mode.
Sessions#
The outermost concept, a workspace that survives disconnect.
Most operator workflows keep one session per project, named so
tmux attach -t NAME brings it back after SSH drops or a
reboot.
Key / Command |
Action |
|---|---|
|
start an unnamed session (auto-numbered) |
|
start a named session |
|
start detached (background only) |
|
list sessions |
|
attach to last session |
|
attach to a named session |
|
switch the current client to a session (from inside tmux) |
|
kill one session |
|
kill the whole server (every session) |
|
detach from current session |
|
detach with chooser (tmux 3+) |
|
interactive session list / switch |
|
rename current session |
|
switch to previous session |
|
switch to next session |
|
switch to last (most recently used) session |
Windows#
The middle layer, equivalent to a browser tab inside a session. Each window is its own full-screen workspace; switching between windows is the fastest way to context-switch without losing state.
Key |
Action |
|---|---|
|
create a new window |
|
rename current window |
|
kill current window (with confirm) |
|
next window |
|
previous window |
|
last window (most recently used) |
|
switch to window N |
|
prompt for window index |
|
interactive window picker (session tree) |
|
find a window by text in its content |
|
move current window to a different index |
|
next window with activity / bell |
|
previous window with activity / bell |
Panes#
Splits inside a window, each running its own shell. Most operator workflows live in panes: editor in one, log tail in another, REPL in a third. Pane navigation and zoom are the bindings that get used most.
Key |
Action |
|---|---|
|
split vertically (left / right) |
|
split horizontally (top / bottom) |
|
move between panes by direction |
|
cycle to the next pane |
|
last (most recently used) pane |
|
flash pane numbers (then digit jumps to that pane) |
|
zoom current pane (toggle) |
|
kill current pane (with confirm) |
|
break current pane out to a new window |
|
swap with previous pane |
|
swap with next pane |
|
cycle through layout presets |
|
apply a specific built-in layout |
|
resize pane by one cell |
|
resize pane by five cells |
|
show a large clock in current pane |
|
display pane info (size, PID, title) |
Copy Mode#
Tmux’s read-only mode for browsing scrollback and copying to the
internal buffer. setw -g mode-keys vi switches to vi-style;
emacs is the default. Enter (emacs) or y (vi) yanks the
selection into the tmux paste buffer.
Emacs-mode selection (default)#
Key |
Action |
|---|---|
|
start selection |
|
copy selection to buffer |
|
copy and exit copy mode |
|
clear selection without copying |
Vi-mode selection (setw -g mode-keys vi)#
Key |
Action |
|---|---|
|
start character-wise selection |
|
line-wise selection |
|
block (rectangular) selection |
|
yank selection to buffer |
|
yank current line |
|
clear selection without yanking |
|
move to start / first non-blank / end of line |
|
word forward / back / end |
|
top / middle / bottom of visible pane |
|
find next / previous character |
Buffers (Paste Stack)#
Tmux maintains a paste-buffer stack across the whole server.
Selections from copy mode push to the top; prefix ] pastes
the top buffer.
Key / Command |
Action |
|---|---|
|
paste the top buffer |
|
choose-buffer (interactive list + paste) |
|
list buffers in the status bar |
|
print buffers (CLI) |
|
print the top buffer |
|
write the top buffer to a file |
|
read a file into a new buffer |
|
load a literal string |
|
drop the top buffer |
|
paste into the active pane (CLI form of |
Command Prompt#
The escape hatch. prefix : opens a prompt that accepts any
tmux command from man tmux. Useful when no binding exists,
or when scripting tmux against itself.
Command (after |
Action |
|---|---|
|
new window with explicit name |
|
split horizontally (left / right) |
|
split vertically (top / bottom) |
|
resize current pane down 5 cells |
|
rename current session |
|
swap with next pane |
|
kill all panes except current |
|
move the status bar to the top |
|
reload config |
|
flash a message in the status bar |
|
run a shell command without disturbing panes |
|
dump current pane buffer to stdout |
|
show the big clock |
|
guarded server kill |
Status / Display#
Key |
Action |
|---|---|
|
large clock |
|
show recent messages |
|
list every binding |
|
reload config (custom binding, common addition) |
|
clear marked pane |
|
mark current pane (for swap-pane / join-pane) |
Mouse Mode#
Enable with set -g mouse on. Tmux then intercepts mouse
events to switch panes, drag-resize borders, and select text in
copy mode. Hold Shift to bypass tmux and pass the click to
the terminal (so the system clipboard / link handler still
work).
Gesture |
Action |
|---|---|
|
select pane |
|
select window (status bar) |
|
resize pane |
|
context menu (tmux 3+) |
|
pane menu (tmux 3+) |
|
enter copy mode and scroll |
|
select text in copy mode (auto-enters) |
|
bypass tmux; pass through to terminal |
Config and Discovery#
Command / file |
Action |
|---|---|
|
per-user config (legacy path) |
|
per-user config (XDG path; tmux 3.1+) |
|
system-wide config |
|
reload config without restarting |
|
list every binding (current key-table) |
|
list copy-mode-vi key-table |
|
show global options |
|
show window-level globals |
|
show session environment |
|
print server / build info |
|
print version |
|
control mode (used by iTerm2 / Termux integrations) |
Useful ~/.tmux.conf#
A starter config that fixes the defaults most operators trip
over: prefix on Ctrl-a, mouse mode on, vi copy mode, larger
scrollback, and Vim-style pane navigation. prefix r reloads
the file so changes take effect without restarting the server.
# Easier prefix
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Mouse mode
set -g mouse on
# Vi-style copy mode
setw -g mode-keys vi
# Renumber windows when one closes
set -g renumber-windows on
# Larger scrollback
set -g history-limit 10000
# Reload binding
bind r source-file ~/.tmux.conf \; display "Reloaded"
# Vim-style pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R