tmux quick reference

Default prefix is Ctrl+b. Replace it below with your configured prefix if different.

sessions

ActionKeys / Command
Start new sessiontmux new -s name
List sessionstmux ls
Attachtmux attach -t name
DetachCtrl+b d
Kill sessiontmux kill-session -t name

windows

ActionKeys
New windowCtrl+b c
List windowsCtrl+b w
Next / previousCtrl+b n · Ctrl+b p
RenameCtrl+b ,
Close windowexit or Ctrl+b &

panes

ActionKeys
Split vertical / horizontalCtrl+b % · Ctrl+b \"
Move between panesCtrl+b + arrow keys
ResizeCtrl+b then Alt + arrows
Rotate panesCtrl+b { · Ctrl+b }
Close paneexit or Ctrl+b x
Sync panes (toggle)Ctrl+b :setw synchronize-panes

copy & paste

ActionKeys
Enter copy modeCtrl+b [
Search/ inside copy mode
Start selectionSpace
Copy selectionEnter
PasteCtrl+b ]

quality-of-life config

# ~/.tmux.conf
set -g mouse on                    # scroll and select with mouse
set -g prefix C-a                  # change prefix to Ctrl+a (optional)
unbind C-b
bind C-a send-prefix
set -g history-limit 20000
bind r source-file ~/.tmux.conf \; display \"config reloaded\"
setw -g mode-keys vi               # vi keys in copy mode
set -g status-interval 30          # status refresh

navigation boosters

ActionKeys
Pane numbers overlayCtrl+b q
Tree view of sessions/windowsCtrl+b s
Choose windowCtrl+b w
Swap panesCtrl+b { · Ctrl+b }
Zoom paneCtrl+b z

save / restore snippets

# Save 200 lines of scrollback from current pane
tmux capture-pane -S -200 -p > scrollback.txt

# Start a named session if missing, else attach
tmux new -A -s main

auto-attach tmux on ssh

Add to your remote ~/.bashrc (or ~/.bash_profile):

if [ -n \"$SSH_CONNECTION\" ] && [ -z \"$TMUX\" ]; then
  tmux new -A -s ssh
  exit
fi

Logs you into session ssh automatically when connecting via SSH; skips if already inside tmux.

Return to Home