Tmux Cheat Sheet

A practical tmux cheatsheet for daily use. Covers essential commands for session control, window switching, pane splitting, and other common tasks.

Tmux Architecture Overview

TMUX SERVER
SESSION: dev
WINDOW 1: editor
Pane 1
Pane 2
WINDOW 2: server
Single Pane
SESSION: logs
WINDOW 1: monitor
Pane 1
Pane 2
Pane 3
Client 1
Client 2
Detached

Tmux Terminology

Server
The background process that manages tmux sessions. A single server can manage multiple sessions.
Session
A collection of windows under a single name. Sessions can be detached (running in background) or attached (displayed in a terminal).
Window
Similar to a tab in a browser, each window occupies the entire terminal screen and can be divided into panes.
Pane
A rectangular division of a window running a single shell or program. Multiple panes can be displayed simultaneously.
Client
A terminal connected to a tmux session. Multiple clients can be attached to the same session simultaneously.
Prefix Key
The key combination (usually Ctrl+b) that signals to tmux that the next keystroke is a tmux command.

Common Pane Layouts Visualized

Even-Horizontal

1
2
3
C-b Alt+1

Even-Vertical

1
2
3
C-b Alt+2

Main-Horizontal

1
2
3
C-b Alt+3

Main-Vertical

1
2
3
C-b Alt+4

Tiled

1
2
3
4
C-b Alt+5

Essential Commands

Most critical commands to get started with tmux

Session Management

  • tmux

    Start a new session

  • tmux new -s name

    Start a new named session

  • tmux ls

    List all sessions

  • tmux a

    Attach to last session

  • tmux a -t name

    Attach to specific session

  • C-b d

    Detach from current session

    C-b means Ctrl+b

  • C-b $

    Rename current session

Window Operations

  • C-b c

    Create a new window

  • C-b ,

    Rename current window

  • C-b n

    Move to next window

  • C-b p

    Move to previous window

  • C-b w

    List all windows

  • C-b 0-9

    Switch to window number 0-9

  • C-b &

    Kill current window

Pane Operations

  • C-b %

    Split pane vertically

  • C-b "

    Split pane horizontally

  • C-b ←↑→↓

    Navigate between panes

    Arrow keys

  • C-b o

    Go to next pane

  • C-b z

    Toggle pane zoom

  • C-b x

    Kill current pane

  • C-b Ctrl+←↑→↓

    Resize pane

    Hold Ctrl and press arrow keys

Copy Mode & Scrolling

  • C-b [

    Enter copy mode

  • q

    Exit copy mode

    When in copy mode

  • PgUp/PgDown

    Scroll page up/down

    When in copy mode

  • ←↑→↓

    Move cursor

    When in copy mode

  • Space

    Start selection

    When in copy mode

  • Enter

    Copy selection

    When in copy mode

  • C-b ]

    Paste copied text

Session Management

Complete reference for creating, navigating, and manipulating tmux sessions

Command Line Management

  • tmux

    Start a new tmux session

    Creates unnamed session

  • tmux new -s mysession

    Start a new named session

    Replace "mysession" with your session name

  • tmux new -s mysession -n mywindow

    Start a new session with a named window

  • tmux attach

    Attach to the most recently used session

  • tmux attach -t mysession

    Attach to a specific session by name

  • tmux ls

    List all running sessions

  • tmux kill-session -t mysession

    Kill/delete a specific session

  • tmux kill-server

    Kill the tmux server and all sessions

    Use with caution - terminates all sessions

  • tmux switch -t mysession

    Switch to a specific session (from within tmux)

  • tmux rename-session -t old-name new-name

    Rename a session from outside tmux

Key Bindings

  • C-b d

    Detach from current session

    Session continues running in background

  • C-b $

    Rename current session

    Shows prompt to enter new name

  • C-b )

    Switch to next session

    Cycles through available sessions

  • C-b (

    Switch to previous session

    Cycles through available sessions

  • C-b s

    Show session list

    Interactive session browser

  • C-b D

    Choose client to detach

    Useful when multiple clients attached

  • C-b :new -s name

    Create new session

    Uses command mode to create session

  • C-b L

    Switch to last session

    Requires custom keybinding in .tmux.conf

Window Controls

Complete reference for managing tmux windows

Basic Operations

  • C-b c

    Create a new window

    Added at the end of the list

  • C-b ,

    Rename current window

    Enter new name when prompted

  • C-b &

    Kill current window

    Prompts for confirmation

  • C-b w

    List all windows

    Shows interactive window list

  • C-b f

    Find window by name

    Enter part of window name to search

Window Navigation

  • C-b n

    Next window

  • C-b p

    Previous window

  • C-b l

    Last active window

    Toggle between current and previous

  • C-b 0-9

    Go to window number 0-9

  • C-b '

    Go to window by index

    Prompts for window index

Window Arrangement

  • C-b .

    Move window to index

    Prompts for new index

  • C-b :

    Enter command mode

    Type "swap-window -t <target>" to swap windows

  • C-b {

    Swap with previous window

    Custom binding in .tmux.conf

  • C-b }

    Swap with next window

    Custom binding in .tmux.conf

Command Line Management

  • tmux new-window

    Create a new window

  • tmux new-window -n name

    Create a new window with specified name

    Replace "name" with your window name

  • tmux select-window -t :0-9

    Select window by index (0-9)

  • tmux select-window -t :name

    Select window by name

  • tmux rename-window "new name"

    Rename current window

  • tmux kill-window

    Kill current window

  • tmux list-windows

    List all windows in current session

Pane Operations

Complete reference for creating, navigating, and manipulating panes

Creation

  • C-b %

    Split pane vertically (left/right)

  • C-b "

    Split pane horizontally (top/bottom)

  • C-b !

    Convert pane into a window

    Creates a new window with this pane

  • C-b x

    Kill (close) the current pane

Navigation

  • C-b ↑↓←→

    Move between panes in the indicated direction

  • C-b o

    Go to next pane (cycle through all panes)

  • C-b ;

    Go to the previously active pane

  • C-b q

    Show pane numbers (press number to jump to that pane)

    Numbers appear briefly - press the number key quickly

  • C-b z

    Toggle zoom (maximize/restore) current pane

Resizing

  • C-b C-↑↓←→

    Resize current pane in the indicated direction

    Hold Ctrl while pressing arrow keys after prefix

  • C-b Alt+↑↓←→

    Resize panes in steps of 5 cells

    Hold Alt (Meta) while pressing arrow keys after prefix

  • C-b :resize-pane -D 10

    Resize down by 10 cells

    Can use -U (up), -L (left), -R (right)

  • C-b {

    Swap current pane with the previous pane

  • C-b }

    Swap current pane with the next pane

Layouts

  • C-b space

    Cycle through preset layouts

  • C-b Alt+1

    Switch to even-horizontal layout

  • C-b Alt+2

    Switch to even-vertical layout

  • C-b Alt+3

    Switch to main-horizontal layout

  • C-b Alt+4

    Switch to main-vertical layout

  • C-b Alt+5

    Switch to tiled layout

Copy Mode & Scrollback

Complete reference for navigating, selecting, and copying text

Basic Operations

  • C-b [

    Enter copy mode

  • q

    Exit copy mode

  • C-b ]

    Paste copied text

    Paste content after copying

Navigation

  • ↑, ↓, ←, →

    Move cursor

    In vi mode: h, j, k, l

  • PgUp, PgDn

    Scroll up/down one page

  • g

    Go to top of buffer

    In vi mode: gg

  • G

    Go to bottom of buffer

    In vi mode: G

  • H, M, L

    Move to top/middle/bottom of screen

  • w, b

    Move forward/backward one word

  • 0, ^, $

    Start/first non-space/end of line

Selection & Copying

  • Space

    Start selection

    In vi mode: v

  • Enter

    Copy selection and exit copy mode

    In vi mode: y

  • Esc

    Clear selection

  • A

    Append selection to buffer

  • R

    Rectangle toggle (block selection)

    In vi mode: C-v

Search

  • /

    Forward search

    Type text and press Enter

  • ?

    Backward search

    Type text and press Enter

  • n

    Next search match

  • N

    Previous search match

  • C-r

    Incremental reverse search

    Vim-style

  • C-s

    Incremental forward search

    Vim-style