Skip to main content

Cheat Sheet

Search and filter tmux commands

All 46 commands

tmux new -s <name>

Create a new named session

tmux ls

List all sessions

(Or: tmux list-sessions)

tmux attach -t <name>

Attach to an existing session

(Or: tmux attach-session -t <name>)

Ctrl+b d

Detach from current session

(Session continues running in background)

tmux kill-session -t <name>

Kill a specific session

Ctrl+b $

Rename current session

(Prompt appears at bottom)

Ctrl+b s

Show all sessions (interactive)

(Navigate and press Enter to attach)

Ctrl+b c

Create a new window

(Windows are numbered starting at 0)

Ctrl+b ,

Rename current window

Ctrl+b n

Switch to next window

Ctrl+b p

Switch to previous window

Ctrl+b 0-9

Switch to window by number

Ctrl+b w

List all windows (interactive)

Ctrl+b &

Kill current window

(Confirms before killing)

Ctrl+b f

Find window by name

(Search prompt appears)

Ctrl+b %

Split pane vertically (left/right)

Ctrl+b "

Split pane horizontally (top/bottom)

Ctrl+b o

Cycle to next pane

Ctrl+b arrow keys

Navigate to pane in direction

(Up, Down, Left, Right)

Ctrl+b q

Show pane numbers (短暂显示)

(Press number to jump to pane)

Ctrl+b z

Toggle zoom current pane

(Expand to fill window, toggle back)

Ctrl+b {

Move pane left (swap)

Ctrl+b }

Move pane right (swap)

Ctrl+b x

Kill current pane

(Confirms before killing)

Ctrl+b Ctrl+arrow

Resize pane in direction

(Hold Ctrl and press arrow repeatedly)

Ctrl+b [

Enter scroll mode (copy mode)

(Use arrows or vi keys to scroll)

Ctrl+b page up/down

Scroll terminal output

(Without entering copy mode)

q or Esc

Exit copy mode

Ctrl+b :

Enter command mode

(Type commands at prompt)

Ctrl+b ?

List all key bindings

(Press q to exit list)

Ctrl+b [

Enter copy mode

Space (start selection)

Begin text selection

(Starts copy mode selection)

Enter (copy selection)

Copy selected text

(Also: Ctrl+w or y depending on mode)

Ctrl+b ]

Paste copied text

(Paste buffer to current pane)

/ (in copy mode)

Search forward

(Search prompt appears)

? (in copy mode)

Search backward

n (in copy mode)

Repeat search in same direction

N (in copy mode)

Repeat search in opposite direction

~/.tmux.conf

Configuration file location

(Create if doesn't exist)

set -g prefix C-a

Change prefix key to Ctrl+a

(Add to .tmux.conf, then: source ~/.tmux.conf)

set -g mouse on

Enable mouse support

(Click to select panes, drag to resize)

set -g status-bg colour

Set status bar background color

(Colours: black, red, green, yellow, blue, magenta, cyan, white)

bind r source-file ~/.tmux.conf \; display 'Reloaded!'

Reload config with Ctrl+b r

(Add to .tmux.conf for quick reload)

set -g base-index 1

Start windows/panes at 1 instead of 0

(Makes keyboard shortcuts more ergonomic)

set -g status-keys vi

Use vi key bindings in command mode

setw -g mode-keys vi

Use vi keys in copy mode

(Default is emacs)