tmux Terminal Multiplexer Manual & Cheat Sheet

tmux is a terminal multiplexer that allows you to create, access, and control multiple terminal sessions from a single screen. It lets you detach from sessions and reattach to them later, keeping your processes running in the background.


Core Concepts

  • Session: A collection of windows managed by tmux. Keeps running even when detached.
  • Window: A single screen within a session (equivalent to tabs in a web browser).
  • Pane: A rectangular division within a window running a separate pseudo-terminal.

Default Prefix Key: Ctrl + b (written below as Prefix). To execute any in-session command, press Prefix, release both keys, and then press the command key.


Session Management (Terminal Commands)

ActionCommand
Start new sessiontmux
Start named sessiontmux new -s <session-name>
List sessionstmux ls (or tmux list-sessions)
Attach to last sessiontmux a (or tmux attach)
Attach to named sessiontmux a -t <session-name>
Kill named sessiontmux kill-session -t <session-name>
Kill all sessions except currenttmux kill-session -a
Kill tmux server (all sessions)tmux kill-server

In-Session Shortcuts

Session Controls

ShortcutAction
Prefix + dDetach from current session
Prefix + (Switch to previous session
Prefix + )Switch to next session
Prefix + sInteractive session selector (tree view)
Prefix + $Rename current session

Window Controls (Tabs)

ShortcutAction
Prefix + cCreate new window
Prefix + ,Rename current window
Prefix + wChoose window from interactive list
Prefix + nMove to next window
Prefix + pMove to previous window
Prefix + 0–9Select window by number
Prefix + &Kill current window
Prefix + .Move/re-number current window

Pane Controls (Splits)

ShortcutAction
Prefix + %Split pane vertically (left / right)
Prefix + "Split pane horizontally (top / bottom)
Prefix + Arrow KeyMove focus to adjacent pane
Prefix + ;Toggle to last active pane
Prefix + oSwap focus to next pane
Prefix + zToggle pane zoom (fullscreen / restore)
Prefix + xClose/kill current pane
Prefix + {Swap current pane with previous pane
Prefix + }Swap current pane with next pane
Prefix + SpaceToggle preset pane layouts
Prefix + Ctrl + ArrowResize active pane in steps
Prefix + qDisplay pane numbers (type number to focus)
Prefix + !Convert pane into its own window

  1. Enter Copy Mode: Prefix + [
  2. Move cursor using Arrow keys, PageUp/PageDown, or Vim keys (h, j, k, l) if enabled.
  3. Start Selection: Press Space
  4. Copy Selection: Press Enter
  5. Paste Copied Text: Prefix + ]
  6. Exit Copy Mode: q or Esc

Configuration (~/.tmux.conf)

Customise tmux settings by creating or editing ~/.tmux.conf.

# Enable mouse support (clickable panes, windows, scrolling)
set -g mouse on
 
# Use Vi keybindings in copy mode (scrollback navigation)
set -g mode-keys vi
 
# Vim-style copy & paste bindings in copy mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
 
# Set split pane shortcuts to more intuitive keys
bind \\ split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
 
# Easy config reload shortcut
bind r source-file ~/.tmux.conf \; display "Config Reloaded!"
 
# Vim-style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
 
# Enable 256-color support
set -g default-terminal "screen-256color"

To reload configuration without restarting tmux, run:

tmux source ~/.tmux.conf