Tmux β Terminal Multiplexer Cheat Sheet
Prefix Key
Every tmux command is prefixed by the prefix key (default: Ctrl-b). Release Ctrl-b before pressing the command key.
To change prefix to Ctrl-a (like GNU Screen), add to ~/.tmux.conf:
Session Management
Sessions contain one or more windows. Use sessions for separate projects or contexts.
| Command | Action |
|---|---|
tmux new -s <name> |
Create new named session |
tmux ls |
List all sessions |
tmux attach -t <name> |
Attach to existing session |
tmux kill-session -t <name> |
Kill a session |
tmux rename-session -t <old> <new> |
Rename session |
tmux switch -t <name> |
Switch to another session |
tmux new -s <name> -d |
Create session in background (detached) |
Inside tmux:
| Command | Action |
|---|---|
Ctrl-b s |
Interactive session list (arrow keys to select) |
Ctrl-b $ |
Rename current session |
Ctrl-b d |
Detach current session (runs in background) |
Ctrl-b ( / Ctrl-b ) |
Switch to previous / next session |
Window Management
Windows are tabs within a session.
| Command | Action |
|---|---|
Ctrl-b c |
Create new window |
Ctrl-b , |
Rename current window |
Ctrl-b & |
Kill current window (confirm) |
Ctrl-b n |
Next window |
Ctrl-b p |
Previous window |
Ctrl-b 0-9 |
Switch to window by number |
Ctrl-b w |
Interactive window list |
Ctrl-b f |
Find window by name (search) |
Ctrl-b . |
Move window (prompt for index number) |
Ctrl-b l |
Toggle to last (previously active) window |
Pane Management
Panes split a window into regions.
Creating Panes
| Command | Action |
|---|---|
Ctrl-b " |
Split horizontally (top/bottom) |
Ctrl-b % |
Split vertically (left/right) |
Navigating Panes
| Command | Action |
|---|---|
Ctrl-b ββββ (arrow keys) |
Move to pane in direction |
Ctrl-b q |
Show pane numbers (press number to jump) |
Ctrl-b o |
Cycle through panes |
Ctrl-b ; |
Toggle to last active pane |
Resizing Panes
| Command | Action |
|---|---|
Ctrl-b Ctrl-ββββ |
Resize pane 1 cell at a time |
Ctrl-b M-ββββ (Alt+arrow) |
Resize pane 5 cells at a time |
Or enter resize mode with Ctrl-b :resize-pane:
# In tmux command mode (:)
resize-pane -D 20 # resize down 20 cells
resize-pane -U 10 # resize up 10 cells
resize-pane -L 15 # resize left 15 cells
resize-pane -R 25 # resize right 25 cells
Pane Layouts
| Command | Action |
|---|---|
Ctrl-b space |
Cycle through preset layouts |
Ctrl-b M-1 to M-5 |
Set layout: even-horizontal, even-vertical, main-horizontal, main-vertical, tiled |
Ctrl-b z |
Zoom pane (toggle fullscreen for current pane) |
Ctrl-b ! |
Break pane into a new window |
Ctrl-b x |
Kill current pane (confirm) |
Ctrl-b { / Ctrl-b } |
Swap pane left / right (or up / down) |
Ctrl-b q |
Show pane numbers briefly |
Synchronizing Panes
Send the same keyboard input to all panes in the same window:
Toggle with: Ctrl-b : then set synchronize-panes
Copy Mode & Scrolling
Tmux has its own scrollback buffer. Mouse scroll wheel scrolls the buffer only if the mouse mode is on.
Entering / Exiting Copy Mode
| Command | Action |
|---|---|
Ctrl-b [ |
Enter copy (scrollback) mode |
Ctrl-b ] |
Paste from tmux buffer |
q or Enter |
Exit copy mode |
Navigation in Copy Mode (vi keys)
| Key | Action |
|---|---|
β / β |
Scroll line by line |
Ctrl-u / Ctrl-d |
Half page up / down |
Ctrl-b / Ctrl-f |
Full page up / down |
g / G |
Go to top / bottom of buffer |
h / l |
Move left / right character |
j / k |
Move down / up line |
w / b |
Jump word forward / backward |
0 / $ |
Jump to start / end of line |
Copying in Copy Mode (vi keys)
| Command | Action |
|---|---|
v |
Start selection (character mode) |
V |
Start selection (line mode) |
Ctrl-v |
Start selection (block mode) |
y |
Yank (copy) selection to tmux buffer |
Enter |
Copy selection and exit copy mode |
Using mouse: Enable mouse support, then drag to select and release to copy.
Buffers (Clipboard)
| Command | Action |
|---|---|
Ctrl-b = |
List / choose from paste buffers |
Ctrl-b ] |
Paste most recent buffer |
tmux save-buffer -b <name> |
Save buffer to file |
tmux set-buffer -b <name> |
Load text into buffer |
Mouse Support
Enable mouse mode (recommended for beginners):
Once enabled:
- Click panes / window tabs to switch
- Scroll with mouse wheel to browse scrollback
- Drag pane borders to resize
- Drag & select text to copy to system clipboard (hold Shift on some terminals to bypass tmux)
Command Mode
Press Ctrl-b : to enter the tmux command prompt. Then type any of these:
| Command | Action |
|---|---|
set -g <option> <value> |
Set global option |
setw -g <option> <value> |
Set window option |
display-message "text" |
Show message in status bar |
show-options -g |
List all global options |
show-window-options -g |
List all window options |
kill-session |
Kill current session |
new-window |
Create new window |
rename-window <name> |
Rename current window |
split-window -h |
Split horizontally |
split-window -v |
Split vertically |
list-keys |
Show all keybindings |
source-file ~/.tmux.conf |
Reload config (apply changes) |
Status Bar Configuration
Set in ~/.tmux.conf:
# Status bar colors
set -g status-bg colour235
set -g status-fg colour255
# Left side: session name
set -g status-left '#[fg=green]#S '
set -g status-left-length 40
# Right side: date/time
set -g status-right '#[fg=yellow]%Y-%m-%d %H:%M'
# Center: window list
set -g status-justify centre
# Interval (seconds) to update status bar
set -g status-interval 5
# Refresh client automatically
set -g set-titles on
Essential ~/.tmux.conf Snippets
256 Colors & True Color
Vi-style Copy Mode Keys
Start Window Numbering at 1
Rebind Reload to Ctrl-b r
Increase Scrollback History
Easy Pane Splitting (no prefix needed for alt keys β vim-like)
Smart Pane Resizing (hold prefix + H/J/K/L)
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
Quick Reference Card
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β tmux Quick Reference β
βββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Ctrl-b c new window Ctrl-b d detachβ
β Ctrl-b , rename window Ctrl-b s sessionβ
β Ctrl-b n/p next/prev window Ctrl-b $ renameβ
β Ctrl-b " split horiz. Ctrl-b % vert. β
β Ctrl-b ββ pane navigation Ctrl-b z zoom β
β Ctrl-b [ copy mode Ctrl-b ] pasteβ
β Ctrl-b : command prompt Ctrl-b ? keys β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Troubleshooting
| Problem | Fix |
|---|---|
| Tmux not found | sudo apt install tmux (Debian/Ubuntu), brew install tmux (macOS), sudo dnf install tmux (Fedora) |
| Colors look wrong | Set default-terminal "tmux-256color" and TERM=xterm-256color outside tmux |
| Can't scroll with mouse | Enable set -g mouse on in config |
| Scrollback too small | Increase history-limit (set before creating sessions) |
| Copy-paste not working with system clipboard | Install xclip or xsel on Linux, then add: set -g set-clipboard on |
| Config not applying | Run tmux source-file ~/.tmux.conf or Ctrl-b :source-file ~/.tmux.conf |