Skip to content

โœ‰๏ธ Discover TinkMail

Powerful email solutions for personal and business use

Get Started Free

Tmux Cheat Sheet โ€‹

๐ŸŽซ Content is validated at 2023-05-01 for
โœ… Ubuntu 22.04
โœ… Debian 11.6
โœ… CentOS 7.9
โœ… MacOS 13.2

This cheat sheet provides a quick reference for the most commonly used tmux commands. All commands require the prefix key (by default Ctrl+b) to be pressed first, followed by the command key.

Session Management โ€‹

CommandDescription
tmuxStart a new tmux session
tmux new -s nameStart a new named session
tmux lsList all sessions
tmux attach -t nameAttach to a named session
tmux kill-session -t nameKill a named session
tmux kill-serverKill all sessions and the tmux server

Prefix Key Combinations โ€‹

All the following commands require pressing the prefix key (Ctrl+b by default) first:

Session Commands โ€‹

KeyDescription
dDetach from current session
sList sessions
$Rename session
(Switch to previous session
)Switch to next session

Window Commands โ€‹

KeyDescription
cCreate new window
nNext window
pPrevious window
wList windows
,Rename current window
&Close current window
0-9Switch to window number

Pane Commands โ€‹

KeyDescription
%Split pane vertically
"Split pane horizontally
oSwitch to next pane
;Switch to last active pane
xClose current pane
zToggle pane zoom
{Move current pane left
}Move current pane right
spaceToggle between pane layouts
qShow pane numbers
Up/Down/Left/RightSwitch to pane in specified direction (with mouse mode)

Copy Mode โ€‹

KeyDescription
[Enter copy mode
]Paste copied text
PgUp/PgDnPage up/down in copy mode
/Search forward
?Search backward

Advanced Pane Management โ€‹

CommandDescription
Ctrl+b Ctrl+oRotate panes forward
Ctrl+b !Convert pane to window
Ctrl+b Ctrl+Left/Right/Up/DownResize pane
Ctrl+b Alt+1Evenly distribute panes
Ctrl+b qShow pane numbers (temporarily)

Copy Mode Navigation (Vim Style) โ€‹

When in copy mode (Ctrl+b [), you can use vim-style navigation:

KeyDescription
h/j/k/lMove left/down/up/right
w/WMove to next word/start of next word
b/BMove to previous word/start of previous word
0/^Move to beginning of line
$Move to end of line
H/M/LMove to top/middle/bottom of screen
gg/GMove to top/bottom of buffer
Ctrl+u/dMove half page up/down
Ctrl+b/fMove page up/down

Copy Mode Operations โ€‹

KeyDescription
SpaceStart selection
EnterCopy selection
EscClear selection
vStart selecting in character mode
VStart selecting in line mode
Ctrl+vStart selecting in block mode

Customization Tips โ€‹

Change Prefix Key โ€‹

To change the prefix key from Ctrl+b to Ctrl+a (like GNU Screen), add this to ~/.tmux.conf:

bash
unbind C-b
set -g prefix C-a
bind C-a send-prefix

Enable Mouse Support โ€‹

bash
set -g mouse on

Reload Configuration โ€‹

After modifying ~/.tmux.conf:

sh
Ctrl+b : source-file ~/.tmux.conf

Status Bar Customization โ€‹

Common status bar customizations for ~/.tmux.conf:

bash
# Change status bar colors
set -g status-style bg=blue,fg=white

# Show system stats
set -g status-right "#[fg=white,bg=black] #H #[fg=white,bg=blue] %H:%M %d-%b-%y "

# Show window list with better formatting
set -g status-justify centre
setw -g window-status-format "#I:#W#F"
setw -g window-status-current-format "#I:#W#F"

Quick Reference Summary โ€‹

  • Prefix key: Ctrl+b (default)
  • Create session: tmux new -s session_name
  • Detach: Ctrl+b d
  • Reattach: tmux attach -t session_name
  • New window: Ctrl+b c
  • Split pane: Ctrl+b % (vertical) or Ctrl+b " (horizontal)
  • Switch panes: Ctrl+b o or arrow keys (with mouse mode)
  • Copy mode: Ctrl+b [
  • Paste: Ctrl+b ]

This cheat sheet covers the most essential tmux commands. With these, you'll be able to efficiently manage multiple terminal sessions and workflows.