Skip to content

tmux Cheat Sheet

The default prefix key is Ctrl+b (shown as C-b below).

CommandDescription
tmuxStart new session
tmux new -s nameStart named session
tmux lsList sessions
tmux attachAttach to last session
tmux attach -t nameAttach to named session
tmux kill-session -t nameKill session
tmux kill-serverKill all sessions
KeybindingDescription
C-b dDetach from session
C-b $Rename session
C-b sList/switch sessions
C-b (Previous session
C-b )Next session
C-b LLast (previous) session
KeybindingDescription
C-b cCreate new window
C-b ,Rename current window
C-b &Close current window
C-b wList windows (interactive)
C-b nNext window
C-b pPrevious window
C-b lLast (toggle) window
C-b 0-9Switch to window 0-9
C-b 'Switch to window by number
C-b .Move window to another index
C-b fFind window by name
KeybindingDescription
C-b %Split horizontally (left/right)
C-b "Split vertically (top/bottom)
KeybindingDescription
C-b ←↑↓→Move to pane in direction
C-b oCycle through panes
C-b ;Toggle last active pane
C-b qShow pane numbers
C-b q 0-9Switch to pane by number
KeybindingDescription
C-b C-←↑↓→Resize pane (small increment)
C-b M-←↑↓→Resize pane (large increment)
C-b zToggle pane zoom (fullscreen)
C-b !Convert pane to window
KeybindingDescription
C-b SpaceCycle through layouts
C-b M-1Even horizontal
C-b M-2Even vertical
C-b M-3Main horizontal
C-b M-4Main vertical
C-b M-5Tiled
KeybindingDescription
C-b xKill pane (with confirmation)
C-b {Swap pane with previous
C-b }Swap pane with next
C-b C-oRotate panes forward
C-b M-oRotate panes backward
KeybindingDescription
C-b [Enter copy mode
C-b ]Paste buffer
C-b =Choose buffer to paste
C-b #List buffers
qExit copy mode
KeybindingDescription
SpaceStart selection
EnterCopy selection and exit
EscapeClear selection
vBegin selection (if vi-copy)
yYank selection (if vi-copy)
/Search forward
?Search backward
nNext search result
NPrevious search result
gGo to top
GGo to bottom
h j k lMove cursor
w bWord forward/backward
0 $Start/end of line
C-u C-dHalf page up/down
C-b C-fFull page up/down
KeybindingDescription
C-b :Enter command mode
Terminal window
# In command mode (C-b :)
source-file ~/.tmux.conf # Reload config
list-keys # List all keybindings
list-commands # List all commands
display-message "text" # Show message
set -g option value # Set global option
setw -g option value # Set window option
# Pane operations
swap-pane -s 0 -t 1 # Swap panes
join-pane -s 1 -t 0 # Join pane from window 1
break-pane # Move pane to new window
# Sync panes (type in all panes simultaneously)
setw synchronize-panes on
setw synchronize-panes off
Terminal window
# Change prefix to C-a
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Enable mouse
set -g mouse on
# Start windows and panes at 1
set -g base-index 1
setw -g pane-base-index 1
# Vi mode
setw -g mode-keys vi
# Better splits (| and -)
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Vim-style pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Resize panes with vim keys
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 reload
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Don't rename windows automatically
set -g allow-rename off
# Increase history limit
set -g history-limit 50000
# Faster escape time (for vim)
set -sg escape-time 0
# 256 color support
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",*256col*:Tc"
# Status bar
set -g status-position top
set -g status-style 'bg=#333333 fg=#ffffff'
set -g status-left '#[fg=green]#S '
set -g status-right '%H:%M %d-%b'
# Active window
setw -g window-status-current-style 'fg=black bg=white'
# Pane borders
set -g pane-border-style 'fg=#444444'
set -g pane-active-border-style 'fg=#00ff00'
#!/bin/bash
SESSION="dev"
# Create session with first window
tmux new-session -d -s $SESSION -n "editor"
# Create additional windows
tmux new-window -t $SESSION -n "server"
tmux new-window -t $SESSION -n "logs"
# Split the editor window
tmux select-window -t $SESSION:editor
tmux split-window -h
tmux split-window -v
# Run commands in panes
tmux send-keys -t $SESSION:editor.0 'nvim' C-m
tmux send-keys -t $SESSION:server 'npm run dev' C-m
tmux send-keys -t $SESSION:logs 'tail -f /var/log/app.log' C-m
# Attach to session
tmux attach -t $SESSION
Terminal window
# Format: session:window.pane
tmux send-keys -t mysession:0.1 'ls' C-m
tmux select-window -t mysession:editor
tmux select-pane -t mysession:0.2
Terminal window
# Toggle sync
C-b : setw synchronize-panes on
# Type command (appears in all panes)
# Toggle off
C-b : setw synchronize-panes off
Terminal window
C-b : capture-pane -S -3000
C-b : save-buffer ~/tmux.log
Terminal window
C-b : pipe-pane -o 'cat >> ~/output.log'
Terminal window
C-b : clear-history
Terminal window
tmux list-keys
tmux list-keys | grep split # Filter
TaskCommand
New sessiontmux new -s name
Attachtmux attach -t name
DetachC-b d
New windowC-b c
Split horizontalC-b %
Split verticalC-b "
Navigate panesC-b arrows
Zoom paneC-b z
Kill paneC-b x
Copy modeC-b [
PasteC-b ]
Command modeC-b :
List sessionsC-b s
List windowsC-b w