Tmux Cheat Sheet

A complete reference of Tmux commands for terminal multiplexing. Find session, window, and pane management commands with examples and keyboard shortcuts.

34 commands found
Filter by category:

tmux new-session

Session

Create a new tmux session

Syntax:

tmux new-session [-d] [-s session-name] [command]

Examples:

tmux new-session Create a new session with default name
tmux new-session -s mysession Create session named 'mysession'
tmux new-session -d -s background Create detached session named 'background'
tmux new -s work Shorthand for creating session 'work'

Notes:

Use -d flag to create detached session (runs in background)

tmux attach-session

Session

Attach to an existing tmux session

Syntax:

tmux attach-session [-t session-name]

Examples:

tmux attach-session Attach to most recent session
tmux attach-session -t mysession Attach to session named 'mysession'
tmux attach -t work Shorthand for attaching to 'work' session
tmux a -t 0 Attach to session with ID 0

Notes:

If no session name specified, attaches to the most recently used session

tmux list-sessions

Session

List all tmux sessions

Syntax:

tmux list-sessions

Examples:

tmux list-sessions Show all active sessions
tmux ls Shorthand for listing sessions
tmux list-sessions -F '#{session_name}: #{session_windows} windows' Custom format showing session name and window count

Notes:

Shows session name, number of windows, creation time, and attached status

tmux kill-session

Session

Terminate a tmux session

Syntax:

tmux kill-session [-t session-name]

Examples:

tmux kill-session -t mysession Kill session named 'mysession'
tmux kill-session -t 0 Kill session with ID 0
tmux kill-server Kill all sessions and the tmux server

Notes:

Killing a session will terminate all windows and panes within it

Prefix + d

Session

Detach from current session

Syntax:

Ctrl-b d (default prefix)

Examples:

Ctrl-b d Detach from current session
Ctrl-b D Detach and choose which client to detach

Notes:

Session continues running in background after detaching

Prefix + c

Window

Create a new window

Syntax:

Ctrl-b c (default prefix)

Examples:

Ctrl-b c Create new window with next available number
tmux new-window Create new window from command line
tmux new-window -n 'logs' Create new window named 'logs'

Notes:

New window starts at current working directory of the session

Prefix + w

Window

List all windows in current session

Syntax:

Ctrl-b w (default prefix)

Examples:

Ctrl-b w Show window list with preview
tmux list-windows List windows from command line
tmux lsw Shorthand for listing windows

Notes:

Use arrow keys to navigate and Enter to select a window

Prefix + [0-9]

Window

Switch to window by number

Syntax:

Ctrl-b [number] (default prefix)

Examples:

Ctrl-b 0 Switch to window 0
Ctrl-b 1 Switch to window 1
Ctrl-b 9 Switch to window 9
Ctrl-b ' Switch to window by name (prompt)

Notes:

Windows are numbered starting from 0

Prefix + n

Window

Move to next window

Syntax:

Ctrl-b n (default prefix)

Examples:

Ctrl-b n Go to next window
Ctrl-b p Go to previous window
Ctrl-b l Go to last used window

Notes:

Cycles through windows in order

Prefix + ,

Window

Rename current window

Syntax:

Ctrl-b , (default prefix)

Examples:

Ctrl-b , Rename current window (interactive)
tmux rename-window newname Rename window from command line

Notes:

Window names appear in the status bar

Prefix + &

Window

Close current window

Syntax:

Ctrl-b & (default prefix)

Examples:

Ctrl-b & Close current window (with confirmation)
exit Close window by exiting shell
tmux kill-window -t 1 Kill window 1 from command line

Notes:

Closing the last window in a session will terminate the session

Prefix + %

Pane

Split pane horizontally (side by side)

Syntax:

Ctrl-b % (default prefix)

Examples:

Ctrl-b % Split current pane horizontally
tmux split-window -h Split horizontally from command line
tmux split-window -h -c '#{pane_current_path}' Split horizontally in same directory

Notes:

Creates a new pane to the right of the current pane

Prefix + "

Pane

Split pane vertically (top and bottom)

Syntax:

Ctrl-b " (default prefix)

Examples:

Ctrl-b " Split current pane vertically
tmux split-window -v Split vertically from command line
tmux split-window -v -c '#{pane_current_path}' Split vertically in same directory

Notes:

Creates a new pane below the current pane

Prefix + arrow keys

Pane

Navigate between panes

Syntax:

Ctrl-b [←→↑↓] (default prefix)

Examples:

Ctrl-b ← Move to pane on the left
Ctrl-b → Move to pane on the right
Ctrl-b ↑ Move to pane above
Ctrl-b ↓ Move to pane below
Ctrl-b o Cycle through panes

Notes:

Use arrow keys or 'o' to move between panes

Prefix + Ctrl + arrow keys

Pane

Resize panes

Syntax:

Ctrl-b Ctrl-[←→↑↓] (default prefix)

Examples:

Ctrl-b Ctrl-← Resize pane left
Ctrl-b Ctrl-→ Resize pane right
Ctrl-b Ctrl-↑ Resize pane up
Ctrl-b Ctrl-↓ Resize pane down
tmux resize-pane -L 5 Resize current pane 5 cells left

Notes:

Hold Ctrl and use arrow keys to resize incrementally

Prefix + x

Pane

Close current pane

Syntax:

Ctrl-b x (default prefix)

Examples:

Ctrl-b x Close current pane (with confirmation)
exit Close pane by exiting shell
tmux kill-pane -t 1 Kill pane 1 from command line

Notes:

Closing the last pane in a window will close the window

Prefix + z

Pane

Toggle pane zoom (fullscreen)

Syntax:

Ctrl-b z (default prefix)

Examples:

Ctrl-b z Toggle fullscreen for current pane

Notes:

Press again to return to multi-pane view

Prefix + spacebar

Pane

Cycle through pane layouts

Syntax:

Ctrl-b Space (default prefix)

Examples:

Ctrl-b Space Cycle through predefined layouts
tmux select-layout even-horizontal Arrange panes in even horizontal layout
tmux select-layout even-vertical Arrange panes in even vertical layout
tmux select-layout main-horizontal Main pane on top, others below
tmux select-layout main-vertical Main pane on left, others right

Notes:

Available layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, tiled

Prefix + [

Copy Mode

Enter copy mode for scrolling and text selection

Syntax:

Ctrl-b [ (default prefix)

Examples:

Ctrl-b [ Enter copy mode
q Exit copy mode
g Go to top of buffer
G Go to bottom of buffer
/ Search forward
? Search backward

Notes:

Use vi or emacs key bindings to navigate (set in tmux.conf)

Space / v

Copy Mode

Start text selection in copy mode

Syntax:

Space (or v for vi mode)

Examples:

Space Start selection (default mode)
v Start selection (vi mode)
V Start line selection (vi mode)
Enter Copy selection and exit copy mode

Notes:

Selection behavior depends on your key binding mode (vi or emacs)

Prefix + ]

Copy Mode

Paste most recent copied text

Syntax:

Ctrl-b ] (default prefix)

Examples:

Ctrl-b ] Paste last copied text
tmux paste-buffer Paste from command line
tmux list-buffers List all copy buffers
tmux paste-buffer -b 0 Paste from specific buffer

Notes:

Tmux maintains multiple copy buffers with numbered history

Prefix + :

Configuration

Enter command mode

Syntax:

Ctrl-b : (default prefix)

Examples:

Ctrl-b : Open command prompt
:source-file ~/.tmux.conf Reload configuration file
:set -g mouse on Enable mouse support
:set -g status-bg red Change status bar background to red

Notes:

Command mode allows running any tmux command interactively

tmux show-options

Configuration

Display tmux options and their values

Syntax:

tmux show-options [-g] [-s] [-w]

Examples:

tmux show-options -g Show global options
tmux show-options -w Show window options
tmux show-options -s Show server options
tmux show-options -g status Show specific option value

Notes:

Use -g for global, -w for window, -s for server options

tmux set-option

Configuration

Set tmux options

Syntax:

tmux set-option [-g] [-w] option value

Examples:

tmux set-option -g prefix C-a Change prefix key to Ctrl-a
tmux set-option -g mouse on Enable mouse support
tmux set-option -g status-position top Move status bar to top
tmux set-option -w automatic-rename off Disable automatic window renaming

Notes:

Use -g for global options, -w for window options

Prefix + ?

Information

Show key bindings help

Syntax:

Ctrl-b ? (default prefix)

Examples:

Ctrl-b ? Display all key bindings
Ctrl-b t Show current time
tmux info Show session information
tmux list-keys List all key bindings from command line

Notes:

Press q to exit the help screen

Prefix + t

Information

Display a clock in current pane

Syntax:

Ctrl-b t (default prefix)

Examples:

Ctrl-b t Show digital clock
tmux clock-mode Enter clock mode from command line

Notes:

Press any key to exit clock mode

tmux capture-pane

Advanced

Capture pane contents to a buffer

Syntax:

tmux capture-pane [-p] [-t target-pane]

Examples:

tmux capture-pane -p Capture and print current pane contents
tmux capture-pane -t 1 Capture pane 1 contents
tmux capture-pane -S -1000 Capture with scrollback history
tmux capture-pane -p > output.txt Save pane contents to file

Notes:

Useful for saving terminal output or debugging

tmux send-keys

Advanced

Send keystrokes to a pane

Syntax:

tmux send-keys [-t target] keys

Examples:

tmux send-keys -t 1 'ls -la' Enter Send command to pane 1
tmux send-keys 'echo hello' C-m Send command with Enter key
tmux send-keys -t mysession:1.0 'top' Enter Send to specific session:window.pane

Notes:

Useful for automation and sending commands to background sessions

tmux pipe-pane

Advanced

Pipe pane output to a command or file

Syntax:

tmux pipe-pane [-o] [-t target] command

Examples:

tmux pipe-pane -o 'cat >> ~/session.log' Log all output to file
tmux pipe-pane Stop piping (toggle off)
tmux pipe-pane -t 1 'grep ERROR' Filter pane 1 output for errors

Notes:

Use -o flag to only capture visible output, not scrollback

tmux join-pane

Advanced

Move a pane from one window to another

Syntax:

tmux join-pane [-s src-pane] [-t dst-window]

Examples:

tmux join-pane -s 1 -t 0 Move pane 1 to window 0
tmux join-pane -h -s 1 Join pane 1 horizontally to current window
tmux join-pane -v -s mysession:1.0 Join specific pane vertically

Notes:

Use -h for horizontal join, -v for vertical join

Prefix + !

Advanced

Break current pane into a new window

Syntax:

Ctrl-b ! (default prefix)

Examples:

Ctrl-b ! Move current pane to new window
tmux break-pane Break pane from command line
tmux break-pane -t 1 Break specific pane to new window

Notes:

Useful for promoting a pane to its own window

tmux has-session

Scripting

Check if a session exists

Syntax:

tmux has-session [-t session-name]

Examples:

tmux has-session -t mysession Check if 'mysession' exists
tmux has-session -t mysession && echo 'exists' || echo 'not found' Conditional check in script

Notes:

Returns exit code 0 if session exists, 1 if not - useful in scripts

tmux run-shell

Scripting

Run shell command in background

Syntax:

tmux run-shell [-d] command

Examples:

tmux run-shell 'echo hello' Run command and show output in tmux
tmux run-shell -d 'sleep 5 && tmux display-message "Done"' Run command in background

Notes:

Useful for running commands from within tmux configuration

tmux display-message

Scripting

Display a message in the status line

Syntax:

tmux display-message [-p] [message]

Examples:

tmux display-message 'Hello World' Show message in status line
tmux display-message -p '#{session_name}' Print current session name
tmux display-message 'Current time: %H:%M' Show formatted time

Notes:

Use -p flag to print to stdout instead of status line

Pro Tmux Tips

Essential Workflow

  1. tmux new -s work - Start a named session
  2. Ctrl-b c - Create new window
  3. Ctrl-b % - Split pane horizontally
  4. Ctrl-b " - Split pane vertically
  5. Ctrl-b d - Detach from session
  6. tmux attach -t work - Reattach to session

Best Practices

  • Use named sessions for different projects
  • Create a custom ~/.tmux.conf file
  • Learn the default prefix key (Ctrl-b)
  • Use tmux ls to see active sessions
  • Enable mouse mode for easier pane resizing
  • Use copy mode to scroll and select text

Quick Configuration

Add these to your ~/.tmux.conf for a better experience:

# Enable mouse support
set -g mouse on
# Start windows and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
# Reload config with Prefix + r
bind r source-file ~/.tmux.conf \; display "Config reloaded!"