env.dev

tmux Cheat Sheet — Sessions, Windows, Panes & Copy Mode

Quick reference for tmux: sessions, windows, panes, copy mode, resizing, synchronize panes, configuration, and keybindings.

Last updated:

tmux (terminal multiplexer) lets you create, manage, and navigate multiple terminal sessions from a single window. This cheat sheet covers the most essential tmux commands, keybindings, and patterns — organized by sessions, windows, panes, copy mode, and configuration. The default prefix key is Ctrl+b, shown as C-b below. All keybindings listed require pressing the prefix first unless noted otherwise.

How Do You Start and Manage Sessions?

Command / KeybindingDescription
tmuxStart a new unnamed session
tmux new -s nameStart a new session named "name"
tmux lsList all active sessions
tmux attach -t nameAttach to session "name"
tmux attach -dt nameAttach to session, detaching other clients
tmux kill-session -t nameKill session "name"
tmux kill-serverKill all sessions and the tmux server
C-b dDetach from current session
C-b sList and switch between sessions interactively
C-b $Rename current session
C-b (Switch to previous session
C-b )Switch to next session

Window Management

KeybindingDescription
C-b cCreate a new window
C-b ,Rename current window
C-b &Close current window (with confirmation)
C-b wList all windows interactively and switch
C-b nMove to next window
C-b pMove to previous window
C-b 0-9Switch to window by number (e.g. C-b 2)
C-b lToggle to last active window
C-b .Move current window to a new index number
tmux swap-window -t 0Swap current window with window 0

How Do You Split and Navigate Panes?

KeybindingDescription
C-b %Split pane vertically (left/right)
C-b "Split pane horizontally (top/bottom)
C-b oCycle to the next pane
C-b ;Toggle to last active pane
C-b arrow keysMove to pane in that direction
C-b qShow pane numbers, then press number to jump
C-b xClose current pane (with confirmation)
C-b zToggle pane zoom (fullscreen/restore)
C-b {Swap current pane with the previous pane
C-b }Swap current pane with the next pane
C-b SpaceCycle through built-in pane layouts
C-b !Convert current pane into a new window

Resizing Panes

Keybinding / CommandDescription
C-b C-arrow keysResize pane by 1 cell in that direction
C-b M-arrow keysResize pane by 5 cells in that direction
tmux resize-pane -D 10Resize current pane down by 10 cells
tmux resize-pane -U 10Resize current pane up by 10 cells
tmux resize-pane -L 10Resize current pane left by 10 cells
tmux resize-pane -R 10Resize current pane right by 10 cells
tmux resize-pane -ZToggle zoom (same as C-b z)

Copy Mode (Scrollback and Selection)

KeybindingDescription
C-b [Enter copy mode (scrollback navigation)
qExit copy mode
Arrow keys / PgUp / PgDnNavigate in copy mode
g / GJump to top / bottom of buffer (vi mode)
/ or ?Search forward / backward (vi mode)
n / NNext / previous search match
SpaceStart selection (vi mode)
EnterCopy selection and exit copy mode
C-b ]Paste most recent buffer
tmux list-buffersList all paste buffers
tmux show-bufferDisplay contents of the top buffer
tmux save-buffer file.txtSave buffer contents to a file

How Do You Use the tmux Command Prompt?

Keybinding / CommandDescription
C-b :Open the tmux command prompt
C-b ?List all keybindings
tmux list-keysList all keybindings from the shell
tmux list-commandsList all available tmux commands
tmux infoShow every tmux session, window, pane, and status
tmux source-file ~/.tmux.confReload tmux configuration

Useful tmux Commands

CommandDescription
tmux send-keys -t name "cmd" EnterSend keys to a target session/pane
tmux select-layout even-horizontalArrange panes in equal-width columns
tmux select-layout even-verticalArrange panes in equal-height rows
tmux select-layout tiledTile panes evenly in a grid
tmux setw synchronize-panes onSend typed input to all panes in the window
tmux setw synchronize-panes offDisable synchronized pane input
tmux pipe-pane -o "cat >> log.txt"Log all pane output to a file
tmux capture-pane -pS -1000Capture last 1000 lines of pane output to stdout

Configuration (~/.tmux.conf)

SettingDescription
set -g prefix C-aChange prefix key from C-b to C-a
set -g mouse onEnable mouse support (click panes, resize, scroll)
set -g base-index 1Start window numbering at 1 instead of 0
setw -g pane-base-index 1Start pane numbering at 1
set -g default-terminal "tmux-256color"Enable 256-color terminal support
set -g history-limit 50000Increase scrollback buffer to 50000 lines
set -g status-interval 5Refresh status bar every 5 seconds
setw -g mode-keys viUse vi-style keys in copy mode
set -g escape-time 0Remove delay after pressing Escape (useful for vim)
bind r source-file ~/.tmux.confBind r to reload config: C-b r

Frequently Asked Questions

What is the tmux prefix key and how do you change it?

The default tmux prefix is Ctrl+b. All keybindings require pressing this prefix first. To change it to Ctrl+a, add "set -g prefix C-a" and "unbind C-b" to your ~/.tmux.conf, then reload with "tmux source-file ~/.tmux.conf".

How do you scroll up in tmux?

Press C-b [ to enter copy mode, then use arrow keys, Page Up/Down, or vi-style j/k to scroll. Press q to exit copy mode. Alternatively, enable mouse mode with "set -g mouse on" in your ~/.tmux.conf to scroll with the mouse wheel.

How do you copy and paste text in tmux?

Enter copy mode with C-b [, navigate to the start of the text, press Space to begin selection, move to the end, and press Enter to copy. Then press C-b ] to paste. With "setw -g mode-keys vi" in your config, you get vi-style selection and yanking.

What is the difference between a tmux session, window, and pane?

A session is the top-level container that persists even when you detach. A window is like a tab within a session, occupying the full terminal screen. A pane is a split within a window, allowing side-by-side or stacked terminal views. One session can have many windows, and each window can have many panes.

How do you keep tmux sessions running after disconnecting?

tmux sessions persist automatically after you detach (C-b d) or lose your SSH connection. Reconnect with "tmux attach -t session-name" or just "tmux attach" to reattach to the last session. The processes running inside continue uninterrupted.

How do you send the same command to all panes at once?

Enable synchronized panes with "tmux setw synchronize-panes on" or type ":setw synchronize-panes on" from the tmux command prompt (C-b :). Everything you type will be sent to all panes in the current window. Disable it by running the same command with "off".