Tmux Cheatsheet

Comprehensive Tmux cheatsheet covering sessions, windows, panes, copy mode, and .tmux.conf configuration. Default prefix is Ctrl+b.

Updated September 15, 2026

tmuxterminalmultiplexerlinux

Default prefix: Ctrl+b. All key bindings below require pressing prefix first, then the key.


Sessions

Command / KeyAction
tmuxStart new session
tmux new -s nameStart named session
tmux lsList sessions
tmux attach -t nameAttach to named session
tmux kill-session -t nameKill named session
tmux kill-serverKill all sessions
Prefix dDetach from session
Prefix $Rename current session
Prefix sList and switch sessions interactively
Prefix ( / )Switch to prev / next session

Advertisement

Windows

KeyAction
Prefix cCreate new window
Prefix ,Rename current window
Prefix &Kill current window (confirm)
Prefix n / pNext / prev window
Prefix 0-9Switch to window by number
Prefix lLast (most recent) window
Prefix wList windows interactively
Prefix .Move window to a number
Prefix fFind window by name

Panes

Splitting

KeyAction
Prefix %Split vertically (side by side)
Prefix "Split horizontally (top/bottom)
KeyAction
Prefix ArrowMove to pane in direction
Prefix h/j/k/lMove (if vim-style binding set)
Prefix qShow pane numbers, press number to jump
Prefix oCycle through panes
Prefix ;Last active pane

Resizing

KeyAction
Prefix Ctrl+ArrowResize pane by 1
Prefix Alt+ArrowResize pane by 5
Prefix zToggle pane fullscreen (zoom)

Managing

KeyAction
Prefix xKill current pane
Prefix !Break pane into new window
Prefix { / }Swap pane with prev / next
Prefix SpaceCycle pane layouts

Copy Mode

KeyAction
Prefix [Enter copy mode
q or EscExit copy mode
SpaceStart selection (default bindings)
EnterCopy selection and exit
Prefix ]Paste from tmux buffer
Prefix =Choose paste buffer from list

With vi keys in copy mode (requires setw -g mode-keys vi in config):

KeyAction
h/j/k/lMove cursor
vBegin selection
yCopy selection
Ctrl+u / Ctrl+dHalf page up / down
/ / ?Search forward / backward
n / NNext / prev search match

Advertisement

Command Mode

KeyAction
Prefix :Enter command prompt
:new-windowNew window
:kill-paneKill pane
:source-file ~/.tmux.confReload config
:list-keysShow all key bindings
:list-commandsShow all commands

.tmux.conf Essentials

# Change prefix to Ctrl+a (screen-style)
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Vi mode in copy mode
setw -g mode-keys vi

# Mouse support
set -g mouse on

# Start windows and panes at 1
set -g base-index 1
setw -g pane-base-index 1

# Faster key repetition
set -s escape-time 0

# Reload config shortcut
bind r source-file ~/.tmux.conf \; display "Config reloaded"

# Better splits (open in current path)
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

# Status bar
set -g status-bg black
set -g status-fg white
set -g status-interval 1
set -g status-right "%H:%M %d-%b-%y"

# Bigger scrollback buffer
set -g history-limit 50000

Scripting Sessions

# Create detached session with windows
tmux new-session -d -s myapp -n editor
tmux new-window -t myapp -n server
tmux new-window -t myapp -n logs

# Send commands to a pane
tmux send-keys -t myapp:editor "vim ." Enter
tmux send-keys -t myapp:server "npm run dev" Enter

# Attach
tmux attach -t myapp

Synchronized Panes (Broadcast Input to All Panes)

When managing multiple servers simultaneously, send keyboard keystrokes to all panes in the current window at once:

# Toggle pane synchronization on/off
Prefix : set-window-option synchronize-panes on
Prefix : set-window-option synchronize-panes off

# Recommended toggle shortcut in ~/.tmux.conf
bind C-s set-window-option synchronize-panes

Session Persistence & Auto-Restoration (TPM)

Using Tmux Plugin Manager (TPM), save and automatically restore all running tmux sessions across server reboots.

1. Install TPM

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

2. Add to ~/.tmux.conf

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# Automatic session restore on boot
set -g @continuum-restore 'on'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

3. Keybindings for Persistence

KeyAction
Prefix IInstall configured plugins
Prefix UUpdate all plugins
Prefix Ctrl-sSave current tmux session state
Prefix Ctrl-rRestore saved tmux session state

Multi-User Pair Programming Over SSH

Share a single tmux session between two developers with a shared UNIX domain socket:

# Developer 1 creates a shared session with socket permissions
tmux -S /tmp/shared_pair_socket new -s pair_session
chmod 777 /tmp/shared_pair_socket

# Developer 2 attaches to the existing socket
tmux -S /tmp/shared_pair_socket attach -t pair_session