Toolmingo
Guides11 min read

tmux Cheat Sheet: Sessions, Windows, Panes, and Keybindings

A complete tmux cheat sheet — sessions, windows, panes, keybindings, copy mode, plugins, and config. Everything you need to master terminal multiplexing.

tmux lets you run multiple terminal sessions inside one window, detach from them, and reattach later — even after SSH disconnects. This reference covers every command and keybinding you need for daily use.

Quick reference

The 25 tmux operations that cover 90% of daily work. Default prefix is Ctrl+b.

Action Keybinding / Command
New session tmux new -s name
Attach to session tmux attach -t name
List sessions tmux ls
Kill session tmux kill-session -t name
Detach from session prefix d
New window prefix c
Next window prefix n
Previous window prefix p
Go to window N prefix N (0–9)
Rename window prefix ,
Split horizontally (top/bottom) prefix "
Split vertically (left/right) prefix %
Navigate panes prefix ↑↓←→
Close pane prefix x
Zoom pane prefix z
Resize pane prefix Ctrl+↑↓←→
Show pane numbers prefix q
Move pane to new window prefix !
Enter copy mode prefix [
Paste buffer prefix ]
List keybindings prefix ?
Command prompt prefix :
Reload config prefix r (if configured)
Clock mode prefix t
Kill server tmux kill-server

Sessions

Sessions are the top-level containers. Each session can have multiple windows.

# Start a new named session
tmux new-session -s work

# Start a session and run a command
tmux new-session -s logs -d 'tail -f /var/log/app.log'

# List all sessions
tmux list-sessions
tmux ls

# Attach to a session by name
tmux attach-session -t work
tmux a -t work

# Attach to the most recent session
tmux a

# Detach from current session (stays running)
# prefix d

# Switch to another session
# prefix s  (interactive picker)
# prefix $  (rename current session)

# Kill a specific session
tmux kill-session -t work

# Kill all sessions
tmux kill-server

Session keybindings:

Binding Action
prefix d Detach from session
prefix s List and switch sessions
prefix $ Rename current session
prefix ( Switch to previous session
prefix ) Switch to next session
prefix L Switch to last (most recently used) session

Windows

Windows work like tabs. Each session can have unlimited windows.

# Create a new window from the command line
tmux new-window -t work

# Create a named window
tmux new-window -n editor

# List windows in a session
tmux list-windows -t work

Window keybindings:

Binding Action
prefix c Create new window
prefix , Rename current window
prefix & Kill current window (with confirmation)
prefix n Next window
prefix p Previous window
prefix l Last (previously used) window
prefix 0–9 Jump to window by number
prefix w Interactive window list
prefix f Search windows by name
prefix . Move window (prompts for new index)

Panes

Panes split a window into multiple terminals running simultaneously.

# Split current pane horizontally (top and bottom)
tmux split-window

# Split vertically (left and right)
tmux split-window -h

# Split and run a command in the new pane
tmux split-window -h 'htop'

# Send a command to a specific pane without switching to it
tmux send-keys -t work:0.1 'npm run dev' Enter

Pane keybindings:

Binding Action
prefix " Split horizontally (top/bottom)
prefix % Split vertically (left/right)
prefix ↑↓←→ Move between panes
prefix o Cycle to next pane
prefix ; Move to last (previously used) pane
prefix q Show pane numbers (press number to jump)
prefix x Kill current pane
prefix z Toggle pane zoom (fullscreen)
prefix ! Move pane to its own window
prefix { Swap pane with previous
prefix } Swap pane with next
prefix Space Cycle through layout presets

Resize panes:

Binding Action
prefix Ctrl+↑ Resize up (hold Ctrl, press arrow)
prefix Ctrl+↓ Resize down
prefix Ctrl+← Resize left
prefix Ctrl+→ Resize right
prefix Alt+↑ Resize up (5 cells)
prefix Alt+↓ Resize down (5 cells)

Layout presets (prefix Space cycles through):

Layout Description
even-horizontal Panes side by side, equal width
even-vertical Panes stacked, equal height
main-horizontal Large pane on top, others below
main-vertical Large pane on left, others on right
tiled Grid arrangement

Copy mode

Copy mode lets you scroll back through terminal output and copy text.

# Enter copy mode
# prefix [

# Exit copy mode
# q or Escape

Default copy mode keybindings (vi mode):

Binding Action
prefix [ Enter copy mode
q / Escape Exit copy mode
↑↓ / j k Scroll line by line
Ctrl+u / Ctrl+d Scroll half page
Ctrl+b / Ctrl+f Scroll full page
g Jump to top
G Jump to bottom
/ Search forward
? Search backward
n / N Next / previous search match
Space Start selection
Enter Copy selection and exit
prefix ] Paste copied text

Enable vi mode in ~/.tmux.conf:

setw -g mode-keys vi

With vi mode, use v to start selection and y to yank (copy).


~/.tmux.conf

The config file is read at startup from ~/.tmux.conf. Reload without restarting:

# From outside tmux
tmux source-file ~/.tmux.conf

# From inside tmux
# prefix : source-file ~/.tmux.conf

Sensible defaults to start with:

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

# Enable mouse support
set -g mouse on

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

# Re-number windows when one is closed
set -g renumber-windows on

# Increase scrollback buffer
set -g history-limit 10000

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

# Faster key repetition
set -s escape-time 0

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

# Intuitive split pane keybindings (current path)
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

# Move between panes with vim-style keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Resize panes with vim-style 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

# Enable 256 colors and true color
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"

# Status bar
set -g status-position bottom
set -g status-bg colour234
set -g status-fg colour137
set -g status-left '#[fg=colour233,bg=colour241,bold] #S '
set -g status-right '#[fg=colour233,bg=colour241,bold] %H:%M %d-%b-%y '

Scripting and automation

tmux is scriptable — use it to set up development environments automatically.

#!/bin/bash
# dev-env.sh — start a full dev environment

SESSION="dev"

# Create the session (detached)
tmux new-session -d -s $SESSION -n editor

# Window 1: editor
tmux send-keys -t $SESSION:0 "nvim ." Enter

# Window 2: server
tmux new-window -t $SESSION -n server
tmux send-keys -t $SESSION:1 "npm run dev" Enter

# Window 3: split — git on left, tests on right
tmux new-window -t $SESSION -n git
tmux split-window -h -t $SESSION:2
tmux send-keys -t $SESSION:2.0 "git log --oneline -20" Enter
tmux send-keys -t $SESSION:2.1 "npm run test:watch" Enter

# Focus window 1
tmux select-window -t $SESSION:0

# Attach
tmux attach-session -t $SESSION

Useful one-liners:

# Run a command in every pane of a window
tmux set-window-option synchronize-panes on
# (type the same command in all panes simultaneously)
# prefix : set synchronize-panes on
# prefix : set synchronize-panes off

# List all panes in all sessions with their PIDs
tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} #{pane_pid} #{pane_current_command}'

# Kill all sessions except the current one
tmux kill-session -a

# Move a window from one session to another
tmux move-window -s source_session:1 -t target_session:

# Capture pane output to a file
tmux capture-pane -p -t work:0.0 > pane-output.txt

Plugins (TPM)

Tmux Plugin Manager (TPM) extends tmux with community plugins.

Install TPM:

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

Add to ~/.tmux.conf:

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

# Popular plugins
set -g @plugin 'tmux-plugins/tmux-resurrect'   # save/restore sessions
set -g @plugin 'tmux-plugins/tmux-continuum'   # auto-save sessions
set -g @plugin 'tmux-plugins/tmux-yank'        # copy to system clipboard
set -g @plugin 'tmux-plugins/tmux-open'        # open highlighted URL/file
set -g @plugin 'christoomey/vim-tmux-navigator' # seamless vim+tmux navigation

# Initialize TPM (keep this at the very bottom)
run '~/.tmux/plugins/tpm/tpm'

TPM keybindings:

Binding Action
prefix I Install plugins
prefix U Update plugins
prefix Alt+u Uninstall unused plugins

tmux-resurrect:

# prefix Ctrl+s — save session
# prefix Ctrl+r — restore session

Common patterns

Keep a long-running process alive

# Start a detached session running a process
tmux new-session -d -s scraper 'python scraper.py'

# Check on it later
tmux attach -t scraper

# Detach without killing
# prefix d

Pair programming over SSH

# On the server: create a shared session
tmux new-session -s shared

# Second person connects and attaches to the same session
ssh user@server
tmux attach -t shared

Watch a log file in a split pane

# Start in main pane
tmux new-session -s logs

# Split and tail log
tmux split-window -v 'tail -f /var/log/app.log'

Run tests across multiple directories simultaneously

# synchronize-panes lets you type in all panes at once
# prefix : set synchronize-panes on

# Or script it:
for dir in frontend backend api; do
  tmux new-window -n $dir
  tmux send-keys -t $dir "cd $dir && npm test" Enter
done

Comparison: tmux vs screen vs zellij

Feature tmux screen zellij
Sessions Yes Yes Yes
Named windows Yes Yes Yes
Pane splitting Yes Limited Yes
Mouse support Yes (config) Partial Yes (default)
Scripting Excellent Basic Good
Plugin ecosystem Large (TPM) None Growing
Config complexity Medium Low Low
True color Yes No Yes
Active development Yes Minimal Yes
Learning curve Medium Low Low

Common mistakes

Mistake Problem Fix
Closing terminal with active sessions Sessions are lost Use prefix d to detach, not close the terminal
Forgetting tmux a after SSH reconnect Starting fresh session instead of reattaching Always check tmux ls after reconnecting
Using exit instead of prefix d Kills the current shell and pane Use prefix d to detach, keep session alive
Prefix key not responding Wrong prefix configured Check ~/.tmux.conf; default is Ctrl+b
Scrolling doesn't work Not in copy mode Enter copy mode with prefix [, then use arrow keys
Config changes not applied Didn't reload Run tmux source-file ~/.tmux.conf or prefix r
Copy doesn't reach system clipboard tmux clipboard is internal Use tmux-yank plugin or xclip/pbcopy integration
Mouse mode breaks copy-paste Conflict with terminal emulator Hold Shift while selecting to use terminal's native copy

FAQ

How do I copy text from tmux to the system clipboard?

Install the tmux-yank plugin (TPM), which automatically pipes y in copy mode to xclip (Linux) or pbcopy (macOS). Without the plugin, hold Shift and use your terminal emulator's native select — this bypasses tmux mouse mode.

What's the difference between a session, a window, and a pane?

Session → Window → Pane. A session groups windows (like a workspace). A window is one screen with a shell (like a browser tab). A pane is a split within a window — multiple terminals visible at once.

How do I change the prefix key from Ctrl+b?

Add to ~/.tmux.conf:

unbind C-b
set -g prefix C-a
bind C-a send-prefix

Then reload: tmux source-file ~/.tmux.conf.

How do I restore my tmux sessions after a reboot?

Use the tmux-resurrect plugin. Press prefix Ctrl+s to save before rebooting and prefix Ctrl+r to restore after. With tmux-continuum, saves happen automatically every 15 minutes.

Why does my tmux look different on a remote server?

The remote server likely doesn't have your ~/.tmux.conf. Copy it over: scp ~/.tmux.conf user@server:~/. Also, 256-color and true-color support depends on the server's terminal capabilities and your SSH client settings.

How do I kill a frozen pane?

If the pane's process is frozen, use prefix x to kill the pane (confirms before closing). To kill without confirmation: prefix : kill-pane. To kill the whole window: prefix &. If tmux itself is frozen, from another terminal run tmux kill-session -t session-name.

Related tools

Keep reading

All Toolmingotools are free & run in your browser

No sign-up, no upload, no watermark. Your files never leave your device.

Browse all tools