Tmux Cheatsheet

Sessions, windows, panes & key bindings for terminal multiplexing

Linux / Tool
Contents
📺

Sessions

# Create
tmux                            # new session
tmux new -s mysession           # named session

# Detach & attach
# Ctrl+b  d                     # detach
tmux ls                         # list sessions
tmux attach -t mysession        # reattach
tmux a                          # attach last

# Kill
tmux kill-session -t mysession
tmux kill-server                # kill all

# Rename
tmux rename-session -t old new
# Ctrl+b  $                     # rename current
🪟

Windows (Tabs)

# Prefix = Ctrl+b (default)

Ctrl+b  c       # new window
Ctrl+b  ,       # rename window
Ctrl+b  w       # list windows
Ctrl+b  n       # next window
Ctrl+b  p       # previous window
Ctrl+b  0-9     # go to window N
Ctrl+b  &       # kill window
Ctrl+b  l       # last active window
🔲

Panes (Splits)

Ctrl+b  %       # split vertical
Ctrl+b  "       # split horizontal
Ctrl+b  ←↑→↓   # navigate panes
Ctrl+b  o       # next pane
Ctrl+b  x       # kill pane
Ctrl+b  z       # toggle zoom (fullscreen pane)
Ctrl+b  {       # swap with previous
Ctrl+b  }       # swap with next
Ctrl+b  Space   # cycle layouts
Ctrl+b  q       # show pane numbers

# Resize panes
Ctrl+b  Ctrl+←↑→↓  # resize by 1
Ctrl+b  Alt+←↑→↓   # resize by 5
⌨️

Key Bindings Summary

# All start with Ctrl+b (prefix)

# Sessions
d       # detach
$       # rename session
s       # choose session

# Windows
c       # create      &   # kill
n/p     # next/prev   ,   # rename

# Panes
%       # vsplit      "   # hsplit
x       # kill        z   # zoom

# Other
?       # list keys
:       # command prompt
t       # show clock
[       # copy mode
📋

Copy Mode

# Enter copy mode
Ctrl+b  [

# Navigation (vi mode)
h j k l     # move
Ctrl+u/d    # page up/down
/           # search forward
?           # search backward

# Select & copy
Space       # start selection
Enter       # copy & exit
Ctrl+b  ]   # paste
⚙️

Configuration (~/.tmux.conf)

# Change prefix to Ctrl+a
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Mouse support
set -g mouse on

# Start numbering at 1
set -g base-index 1
setw -g pane-base-index 1

# Vi mode
setw -g mode-keys vi

# Better splits
bind | split-window -h
bind - split-window -v

# Reload config
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# 256 colors
set -g default-terminal "screen-256color"
🚀

Advanced

# Send command to all panes
:setw synchronize-panes on

# Move pane to new window
Ctrl+b  !

# Join pane from another window
:join-pane -s 2

# Save/restore sessions (tmux-resurrect plugin)
Ctrl+b  Ctrl+s    # save
Ctrl+b  Ctrl+r    # restore

# Scripted setup
tmux new -d -s dev
tmux send-keys -t dev "vim ." Enter
tmux split-window -t dev -h
tmux send-keys -t dev "npm run dev" Enter
tmux attach -t dev