# tmux Cheatsheet - Cheatsheets - Launch Pad

__ _______________________ _________._________________________ \_ _____/ \______ \ / _ \ / _____/ / _____/ | | \_ _____/ | __) | _/ / /_\ \ / \ ___ / \ ___ | | | __)_ | \ | | \ / | \ \ \_\ \ \ \_\ \ | |___ | \ \___ / |____|_ / \____|__ / \______ / \______ / |_______ \ /_______ / \/ \/ \/ \/ \/ \/ \/

# tmux Cheatsheet

← Back to cheatsheets

← Home

## Basic Commands

### Starting and Attaching

- tmux - Start new session

- tmux new -s <name> - Start new named session

- tmux attach -t <name> - Attach to session

- tmux attach-session -t <name> - Attach to session (long form)

- tmux ls - List all sessions

- tmux list-sessions - List all sessions (long form)

- tmux kill-session -t <name> - Kill a session

- tmux kill-server - Kill all sessions

### Prefix Key

Default prefix is Ctrl+b. All commands below assume this prefix.

## Sessions

- s - List sessions

- $ - Rename session

- d - Detach from session

- ( - Switch to previous session

- ) - Switch to next session

## Windows

- c - Create new window

- , - Rename current window

- w - List windows

- n - Next window

- p - Previous window

- 0-9 - Switch to window number

- & - Kill current window

- f - Find window by name

## Panes

- % - Split pane vertically (left/right)

- " - Split pane horizontally (top/bottom)

- x - Kill current pane

- z - Zoom/unzoom current pane

- { - Swap pane with previous

- } - Swap pane with next

- o - Switch to next pane

- ; - Switch to last active pane

- q - Show pane numbers (then press number to switch)

- h - Select pane to the left

- j - Select pane below

- k - Select pane above

- l - Select pane to the right

- H - Resize pane left

- J - Resize pane down

- K - Resize pane up

- L - Resize pane right

- Ctrl+h/j/k/l - Resize pane (alternative)

- Alt+Arrow - Resize pane

- Space - Toggle between pane layouts

## Copy Mode

- [ - Enter copy mode

- ] - Paste buffer

- q - Exit copy mode

- Space - Start selection

- Enter - Copy selection

- v - Start selection (vi mode)

- y - Copy selection (vi mode)

- p - Paste (vi mode)

- / - Search forward

- ? - Search backward

- n - Next match

- N - Previous match

## Miscellaneous

- t - Show clock

- ? - List all key bindings

- : - Enter command mode

- r - Reload config file

- ~ - Show messages

- Ctrl+z - Suspend tmux (send to background)

## Command Mode Commands

- new-window -n <name> - Create named window

- split-window -h - Split horizontally

- split-window -v - Split vertically

- select-pane -t <number> - Select pane by number

- resize-pane -L 10 - Resize pane left by 10

- resize-pane -R 10 - Resize pane right by 10

- resize-pane -U 10 - Resize pane up by 10

- resize-pane -D 10 - Resize pane down by 10

- swap-pane -s <source> -t <target> - Swap panes

- kill-pane -t <number> - Kill pane

- kill-window -t <number> - Kill window

## Configuration

### Config File Location

- ~/.tmux.conf (user config)

- /etc/tmux.conf (system config)

### Example Key Bindings

Customize key bindings in your config:

    # Change prefix key
    unbind C-b
    set-option -g prefix C-a
    bind-key C-a send-prefix

    # Custom window navigation
    bind h select-pane -L
    bind j select-pane -D
    bind k select-pane -U
    bind l select-pane -R

    # Custom window splitting
    bind | split-window -h
    bind - split-window -v
    unbind '"'
    unbind %

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

### Common Settings

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

    # Enable mouse support
    set -g mouse on

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

    # Renumber windows sequentially after closing any
    set -g renumber-windows on

    # Increase scrollback buffer
    set -g history-limit 10000

    # Enable vi mode
    setw -g mode-keys vi

    # Set default terminal mode to 256color
    set -g default-terminal "screen-256color"

    # Faster key repeat
    set -s escape-time 0

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

## Tips

- Use tmux -2 to force 256 color mode

- Use tmux -u to enable UTF-8

- Sessions persist after terminal closes

- Use tmuxinator or tmuxp for session management

- Ctrl+b then d to detach without killing session

- Use tmux attach to reconnect to last session

← Back to cheatsheets

← Home