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

tmux

start an unnamed session (auto-numbered)

tmux new -s NAME

start a named session

tmux new -s NAME -d

start detached (background only)

tmux ls

list sessions

tmux attach / tmux a

attach to last session

tmux attach -t NAME

attach to a named session

tmux switch -t NAME

switch the current client to a session (from inside tmux)

tmux kill-session -t NAME

kill one session

tmux kill-server

kill the whole server (every session)

prefix d

detach from current session

prefix D

detach with chooser (tmux 3+)

prefix s

interactive session list / switch

prefix $

rename current session

prefix (

switch to previous session

prefix )

switch to next session

prefix L

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

prefix c

create a new window

prefix ,

rename current window

prefix &

kill current window (with confirm)

prefix n

next window

prefix p

previous window

prefix l

last window (most recently used)

prefix 0prefix 9

switch to window N

prefix '

prompt for window index

prefix w

interactive window picker (session tree)

prefix f

find a window by text in its content

prefix .

move current window to a different index

prefix M-n

next window with activity / bell

prefix M-p

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

prefix %

split vertically (left / right)

prefix "

split horizontally (top / bottom)

prefix Up / Down / Left / Right

move between panes by direction

prefix o

cycle to the next pane

prefix ;

last (most recently used) pane

prefix q

flash pane numbers (then digit jumps to that pane)

prefix z

zoom current pane (toggle)

prefix x

kill current pane (with confirm)

prefix !

break current pane out to a new window

prefix {

swap with previous pane

prefix }

swap with next pane

prefix Space

cycle through layout presets

prefix M-1prefix M-5

apply a specific built-in layout

prefix Ctrl-Up / Down / Left / Right

resize pane by one cell

prefix M-Up / Down / Left / Right

resize pane by five cells

prefix t

show a large clock in current pane

prefix i

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.

Common navigation (works in both modes)#

Key

Action

prefix [

enter copy mode

q / Esc

exit copy mode

prefix ]

paste the most recent buffer

Page Up / Page Down

scroll one page

Ctrl-u / Ctrl-d

half-page up / down

/

search forward

?

search backward

n / N

next / previous match

g

jump to top of scrollback

G

jump to bottom of scrollback

Emacs-mode selection (default)#

Key

Action

Ctrl-Space

start selection

Alt-w / Esc w

copy selection to buffer

Ctrl-w

copy and exit copy mode

Ctrl-g

clear selection without copying

Vi-mode selection (setw -g mode-keys vi)#

Key

Action

v

start character-wise selection

V

line-wise selection

Ctrl-v

block (rectangular) selection

y

yank selection to buffer

Y

yank current line

Esc

clear selection without yanking

0 / ^ / $

move to start / first non-blank / end of line

w / b / e

word forward / back / end

H / M / L

top / middle / bottom of visible pane

f<c> / F<c>

find next / previous character c on line

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

prefix ]

paste the top buffer

prefix =

choose-buffer (interactive list + paste)

prefix #

list buffers in the status bar

tmux list-buffers

print buffers (CLI)

tmux show-buffer

print the top buffer

tmux save-buffer FILE

write the top buffer to a file

tmux load-buffer FILE

read a file into a new buffer

tmux set-buffer "text"

load a literal string

tmux delete-buffer

drop the top buffer

tmux paste-buffer

paste into the active pane (CLI form of prefix ])

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 prefix :)

Action

new-window -n NAME

new window with explicit name

split-window -h

split horizontally (left / right)

split-window -v

split vertically (top / bottom)

resize-pane -D 5

resize current pane down 5 cells

rename-session NAME

rename current session

swap-pane -D

swap with next pane

kill-pane -a

kill all panes except current

set -g status-position top

move the status bar to the top

source-file ~/.tmux.conf

reload config

display-message "text"

flash a message in the status bar

run-shell "cmd"

run a shell command without disturbing panes

capture-pane -p

dump current pane buffer to stdout

clock-mode

show the big clock

confirm-before -p 'kill server? (y/n)' kill-server

guarded server kill

Status / Display#

Key

Action

prefix t

large clock

prefix ~

show recent messages

prefix ?

list every binding

prefix r

reload config (custom binding, common addition)

prefix M

clear marked pane

prefix m

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

Click pane

select pane

Click window

select window (status bar)

Drag border

resize pane

Right-click status

context menu (tmux 3+)

Right-click pane

pane menu (tmux 3+)

Scroll wheel

enter copy mode and scroll

Click + drag

select text in copy mode (auto-enters)

Shift + Click

bypass tmux; pass through to terminal

Config and Discovery#

Command / file

Action

~/.tmux.conf

per-user config (legacy path)

~/.config/tmux/tmux.conf

per-user config (XDG path; tmux 3.1+)

/etc/tmux.conf

system-wide config

tmux source-file PATH

reload config without restarting

tmux list-keys / tmux lsk

list every binding (current key-table)

tmux list-keys -T copy-mode-vi

list copy-mode-vi key-table

tmux show-options -g

show global options

tmux show-window-options -g

show window-level globals

tmux show-environment

show session environment

tmux info

print server / build info

tmux -V

print version

tmux -CC

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