Show HN: Yet another tmux cheat sheet

1 day ago 5

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

Tmux Architecture Overview

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

Essential Commands

Most critical commands to get started with tmux

  • Start a new named session

  • Attach to specific session

  • Detach from current session

    C-b means Ctrl+b

  • Switch to window number 0-9

  • Navigate between panes

    Arrow keys

  • Resize pane

    Hold Ctrl and press arrow keys

  • Exit copy mode

    When in copy mode

  • Scroll page up/down

    When in copy mode

  • Move cursor

    When in copy mode

  • Start selection

    When in copy mode

  • Copy selection

    When in copy mode

Session Management

Complete reference for creating, navigating, and manipulating tmux sessions

  • Start a new tmux session

    Creates unnamed session

  • 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

  • Attach to the most recently used session

  • Attach to a specific session by name

  • List all running sessions

  • tmux kill-session -t mysession

    Kill/delete a specific session

  • Kill the tmux server and all sessions

    Use with caution - terminates all sessions

  • Switch to a specific session (from within tmux)

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

    Rename a session from outside tmux

  • Detach from current session

    Session continues running in background

  • Rename current session

    Shows prompt to enter new name

  • Switch to next session

    Cycles through available sessions

  • Switch to previous session

    Cycles through available sessions

  • Show session list

    Interactive session browser

  • Choose client to detach

    Useful when multiple clients attached

  • Create new session

    Uses command mode to create session

  • Switch to last session

    Requires custom keybinding in .tmux.conf

Window Controls

Complete reference for managing tmux windows

  • Create a new window

    Added at the end of the list

  • Rename current window

    Enter new name when prompted

  • Kill current window

    Prompts for confirmation

  • List all windows

    Shows interactive window list

  • Find window by name

    Enter part of window name to search

  • Last active window

    Toggle between current and previous

  • Go to window by index

    Prompts for window index

  • Move window to index

    Prompts for new index

  • Enter command mode

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

  • Swap with previous window

    Custom binding in .tmux.conf

  • Swap with next window

    Custom binding in .tmux.conf

  • 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

  • tmux rename-window "new name"

  • List all windows in current session

Pane Operations

Complete reference for creating, navigating, and manipulating panes

  • Split pane vertically (left/right)

  • Split pane horizontally (top/bottom)

  • Convert pane into a window

    Creates a new window with this pane

  • Kill (close) the current pane

  • Move between panes in the indicated direction

  • Go to next pane (cycle through all panes)

  • Go to the previously active pane

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

    Numbers appear briefly - press the number key quickly

  • Toggle zoom (maximize/restore) current pane

  • Resize current pane in the indicated direction

    Hold Ctrl while pressing arrow keys after prefix

  • Resize panes in steps of 5 cells

    Hold Alt (Meta) while pressing arrow keys after prefix

  • Resize down by 10 cells

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

  • Swap current pane with the previous pane

  • Swap current pane with the next pane

  • Cycle through preset layouts

  • Switch to even-horizontal layout

  • Switch to even-vertical layout

  • Switch to main-horizontal layout

  • Switch to main-vertical layout

Copy Mode & Scrollback

Complete reference for navigating, selecting, and copying text

  • Paste copied text

    Paste content after copying

  • Move cursor

    In vi mode: h, j, k, l

  • Go to top of buffer

    In vi mode: gg

  • Go to bottom of buffer

    In vi mode: G

  • Move to top/middle/bottom of screen

  • Move forward/backward one word

  • Start/first non-space/end of line

  • Start selection

    In vi mode: v

  • Copy selection and exit copy mode

    In vi mode: y

  • Append selection to buffer

  • Rectangle toggle (block selection)

    In vi mode: C-v

  • Forward search

    Type text and press Enter

  • Backward search

    Type text and press Enter

  • Incremental reverse search

    Vim-style

  • Incremental forward search

    Vim-style

Get the Printable Version

Download our comprehensive tmux cheat sheet in PDF format for offline reference. Perfect for printing or keeping handy on your device.

Download PDF Cheat Sheet
Read Entire Article