All cheatsheets

tmux

Common tmux commands and workflows using Ctrl-A as the modifier

TMUX Cheatsheet (with Ctrl+A modifier)

Session Management

CommandAction
tmux new-session -s nameCreate new session named "name"
Ctrl+A :new-session -s nameCreate new session from within tmux
tmux lsList all sessions
Ctrl+A sList sessions (interactive)
tmux attach -t nameAttach to session "name"
Ctrl+A dDetach from current session
Ctrl+A (Switch to previous session
Ctrl+A )Switch to next session
tmux kill-session -t nameKill session "name"
Ctrl+A XKill current session
Ctrl+A $Rename current session

Window Management

CommandAction
Ctrl+A cCreate new window
Ctrl+A nGo to next window
Ctrl+A pGo to previous window
Ctrl+A lGo to last active window
Ctrl+A 0-9Go to window 0-9
Ctrl+A wList windows (interactive)
Ctrl+A ,Rename current window
Ctrl+A &Kill current window
Ctrl+A .Move current window to another position
Ctrl+A :swap-window -t -1Move window left
Ctrl+A :swap-window -t +1Move window right
Ctrl+A fFind window by name

Pane Management

CommandAction
Ctrl+A %Split pane vertically (left/right)
Ctrl+A "Split pane horizontally (top/bottom)
Ctrl+A oGo to next pane
Ctrl+A ;Go to previously active pane
Ctrl+A Up/Down/Left/RightNavigate between panes
Ctrl+A {Swap current pane with previous
Ctrl+A }Swap current pane with next
Ctrl+A xKill current pane
Ctrl+A !Convert pane to window
Ctrl+A zToggle pane zoom (maximize/restore)
Ctrl+A Ctrl+oRotate panes forward
Ctrl+A M-oRotate panes backward
Ctrl+A SpaceCycle through pane layouts
Ctrl+A M-1 to M-5Select specific layout

Pane Resizing

CommandAction
Ctrl+A Ctrl+Up/Down/Left/RightResize pane (1 cell)
Ctrl+A M-Up/Down/Left/RightResize pane (5 cells)
Ctrl+A :resize-pane -U 10Resize pane up 10 cells
Ctrl+A :resize-pane -D 10Resize pane down 10 cells
Ctrl+A :resize-pane -L 10Resize pane left 10 cells
Ctrl+A :resize-pane -R 10Resize pane right 10 cells

Copy Mode

CommandAction
Ctrl+A [Enter copy mode
q or EscExit copy mode
SpaceStart selection
EnterCopy selection and exit copy mode
gGo to top of buffer
GGo to bottom of buffer
/Search forward
?Search backward
nNext match
NPrevious match
wForward word
bBackward word
{Previous paragraph
}Next paragraph
Ctrl+A ]Paste from buffer
Ctrl+A =List buffers
Ctrl+A -Delete last buffer

Command Mode

CommandAction
Ctrl+A :Enter command mode
Ctrl+A ?List all key bindings
Ctrl+A tDisplay time in current pane

Useful Aliases for .tmux.conf

# Navigation
bind -n C-h select-pane -L
bind -n C-j select-pane -D
bind -n C-k select-pane -U
bind -n C-l select-pane -R

# Splitting panes with intuitive keys
bind v split-window -h
bind s split-window -v

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

# Better window navigation
bind -n M-n next-window
bind -n M-p previous-window

# Mouse support
set -g mouse on

Common Workflows

Create a dev environment with 3 panes

tmux new-session -s dev
Ctrl+A %                    # Split vertical (left editor, right monitor)
Ctrl+A "                    # Split bottom pane horizontally
Ctrl+A Left                 # Select left pane
Ctrl+A c                    # Create another window for logs

Quick debugging session

Ctrl+A c                    # New window
Ctrl+A %                    # Split vertical
Ctrl+A Left                 # Navigate to left pane
# Run your app on left, logs/tests on right

Monitor multiple services

tmux new-session -s monitor
Ctrl+A %                    # Service 1
Ctrl+A %                    # Service 2
Ctrl+A o                    # Navigate between services

Useful Commands

CommandPurpose
tmux capture-pane -pPrint pane content
tmux capture-pane -p -S -30Print last 30 lines
tmux send-keys -t session:window "command" EnterSend command to specific pane
tmux send-keys -t session "cd /path && ls" EnterExecute command in session

Tips & Tricks

  • Prefix twice for nested tmux: Ctrl+A Ctrl+A sends Ctrl+A to nested session
  • History size: Add set -g history-limit 50000 to .tmux.conf
  • Aggressive resize: Add setw -g aggressive-resize on for better multi-client handling
  • Status bar: set -g status-position top to move status bar to top
  • Auto-rename windows: setw -g automatic-rename on automatically renames windows based on current command
  • Monitor activity: Ctrl+A M marks current window for monitoring
  • Synchronize panes: Ctrl+A :setw synchronize-panes run command across all panes simultaneously

Basic .tmux.conf Setup

# Set prefix to Ctrl+A
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# Start window numbers at 1
set -g base-index 1
setw -g pane-base-index 1

# Enable mouse
set -g mouse on

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

# Status bar
set -g status-bg black
set -g status-fg white
set -g status-left "[#S]"
set -g status-right "%H:%M %d-%b-%y"

# Key bindings
bind r source-file ~/.tmux.conf \; display "Reloaded!"
bind v split-window -h
bind s split-window -v