Skip to main content

Tmux Command Cheatsheet

Tmux is a powerful terminal multiplexer that lets you create, access, and control multiple terminal sessions from a single window. This cheatsheet covers the most commonly used Tmux operations — session management, window navigation, pane layouts, configuration, and clipboard integration. Start with the prefix key (default Ctrl+b) and basic session operations, then gradually explore pane management and custom configuration.

Updated: 2026-07-16·40 commands

Quick Reference

TaskKey / Command
New sessiontmux new -s name
Detach sessionprefix + d
Reattach sessiontmux attach -t name
New windowprefix + c
Switch windowprefix + number
Vertical splitprefix + %
Horizontal splitprefix + \"
Switch paneprefix + arrow keys
Browse historyprefix + [
List all keybindingsprefix + ?

Session Management

``bash # Create sessions tmux new -s mysession # Create a new session named mysession tmux new # Create an anonymous new session tmux new-session -s web # Create a session named web

# Detach (leave running in background) prefix + d # Detach current session (programs keep running)

# Reattach tmux attach -t mysession # Reattach to mysession tmux a -t mysession # Short form tmux attach # Attach to the only session

# List sessions tmux ls # List all running sessions prefix + s # Interactive session selector inside Tmux

# Kill sessions tmux kill-session -t mysession # Kill a specific session tmux kill-server # Kill Tmux server (all sessions) prefix + & # Kill current window (with confirmation) prefix + x # Kill current pane (with confirmation)

# Rename tmux rename-session -t old new # Rename session from outside prefix + $ # Rename current session inside Tmux

# Switch sessions prefix + ( # Switch to previous session prefix + ) # Switch to next session prefix + w # Menu-based session and window picker `

Window Operations

`bash # Create and close prefix + c # Create a new window prefix + & # Close current window (with confirmation) tmux new-window -n web # Create a named window from command line

# Switch windows prefix + 0-9 # Switch to window by number prefix + p # Previous window prefix + n # Next window prefix + w # List-based window selector prefix + f # Find window by name

# Window management prefix + , # Rename current window prefix + . # Move window (enter new index) prefix + l # Switch to last active window :swap-window -t -1 # Swap with previous window :swap-window -t +1 # Swap with next window tmux move-window -s 1 -t 3 # Move window 1 to position 3

# Window indexing tmux set -g base-index 1 # Start window index at 1 (default 0) :move-window -r # Renumber windows sequentially :display-message -p '#I' # Show current window index `

Pane Operations

`bash # Create panes prefix + % # Vertical split (left/right panes) prefix + " # Horizontal split (top/bottom panes) :split-window -h # Command-based vertical split :split-window -v # Command-based horizontal split

# Pane navigation prefix + ←↑→↓ # Navigate to adjacent pane prefix + o # Cycle to next pane prefix + ; # Go to last active pane prefix + q # Show pane numbers (press number to jump)

# Pane resizing prefix + Ctrl+arrow # Resize pane by 1 unit :resize-pane -D 10 # Resize down 10 lines :resize-pane -U 5 # Resize up 5 lines :resize-pane -L 20 # Resize left 20 columns :resize-pane -R 15 # Resize right 15 columns

# Pane control prefix + ! # Break pane into a standalone window prefix + x # Close current pane (with confirmation) prefix + z # Toggle pane zoom (fullscreen/restore) prefix + space # Cycle through pane layouts prefix + { # Move pane left/up prefix + } # Move pane right/down prefix + q + number # Jump directly to pane by number `

Layout Management

`bash # Built-in layouts prefix + space # Cycle through layouts prefix + M-1 # even-horizontal layout prefix + M-2 # even-vertical layout prefix + M-3 # main-horizontal layout prefix + M-4 # main-vertical layout prefix + M-5 # tiled layout

:select-layout even-horizontal # Command-based layout selection :select-layout tiled # Tiled layout :select-layout -E # Previous layout

# Custom layout :setw -g window-layout tiled # Set default layout for new windows :setw -g force-width 80 # Force pane width :setw -g force-height 40 # Force pane height :join-pane -s web:2.1 # Move pane from session web window 2 pane 1 :join-pane -t .1 # Join current window pane 1 to new position :display-panes # Show all pane numbers

# Synchronized input :setw synchronize-panes on # Type simultaneously in all panes :setw synchronize-panes off # Disable synchronized input prefix + :setw synchronize-panes # Toggle via shortcut

# Save/restore layout tmux list-windows -a # List all window layout info :show-window-options -g # View global window options :save-buffer ~/tmux-layout.txt # Save buffer to file `

Configuration

`bash # ~/.tmux.conf example # Change prefix key set -g prefix C-a # Change prefix to Ctrl+a unbind C-b # Unbind default prefix bind C-a send-prefix # Double-tap to send prefix

# Mouse support set -g mouse on # Enable mouse (click/drag/scroll)

# Appearance set -g default-terminal "screen-256color" # 256-color terminal support set -g status-bg colour235 # Status bar background set -g status-fg white # Status bar foreground set -g status-left-length 40 # Max left status length set -g status-right-length 80 # Max right status length set -g status-justify centre # Center-align status items set -g status-interval 5 # Status refresh interval (seconds)

# Status bar content set -g status-left "#[fg=green]Session: #S " set -g status-right "#[fg=yellow]%Y-%m-%d %H:%M " set -g window-status-current-format "#[fg=cyan,bold]#I:#W" set -g window-status-format "#[fg=white]#I:#W"

# Key binding optimizations bind r source-file ~/.tmux.conf \; display-message "Config reloaded" # Ctrl+b r reload bind | split-window -h # Use | for vertical split bind - split-window -v # Use - for horizontal split bind H resize-pane -L 5 # Quick resize left bind J resize-pane -D 5 # Quick resize down bind K resize-pane -U 5 # Quick resize up bind L resize-pane -R 5 # Quick resize right

# Display settings set -g display-time 3000 # Show messages for 3 seconds set -g message-style "bg=colour235,fg=white" set -g message-command-style "bg=colour235,fg=yellow"

# History buffer set -g history-limit 50000 # Max history lines per pane setw -g mode-keys vi # Use vi key bindings in copy mode `

Clipboard & Copy Mode

`bash # Enter copy mode prefix + [ # Enter copy mode (scroll through history) prefix + PageUp # Enter copy mode and scroll up :capture-pane -S - # Capture full pane content to buffer

# Copy mode operations (vi mode) # Requires: setw -g mode-keys vi h / j / k / l # Move left / down / up / right Ctrl+b / Ctrl+f # Page up / page down gg / G # Go to top / bottom 0 / $ # Line start / end /pattern # Search forward ?pattern # Search backward n / N # Next / previous match

# Select and copy Space # Start text selection Enter # Copy selection to Tmux buffer prefix + ] # Paste from Tmux buffer

# Vi-style copy mode bindings (recommended) # bind -T copy-mode-vi v send-keys -X begin-selection # bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel # bind -T copy-mode-vi C-v send-keys -X rectangle-toggle

# System clipboard integration # Linux (requires xclip) set -g set-clipboard on bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -selection clipboard" bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -selection clipboard"

# macOS (uses pbcopy) # bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" # bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"

# Buffer management :show-buffer # Show current buffer content :list-buffers # List all buffers :choose-buffer # Interactive buffer selector :save-buffer ~/output.txt # Save buffer to file :delete-buffer # Delete current buffer :clear-history # Clear current pane history ``

Session(7)

CommandLevel
tmux new -s <name>
Create a new named Tmux session
Basic
prefix + d
Detach current session (programs keep running)
Basic
tmux attach -t <name>
Reattach to a named session
Basic
tmux ls
List all running Tmux sessions
Basic
tmux kill-session -t <name>
Kill a specific Tmux session
Basic
tmux kill-server
Kill the Tmux server and all sessions
Intermediate
prefix + $ / tmux rename-session
Rename the current session
Basic

Window(5)

CommandLevel
prefix + c
Create a new window
Basic
prefix + 0-9
Switch to window by index number
Basic
prefix + p / prefix + n
Switch to previous/next window
Basic
prefix + w
Browse and select windows from a list
Intermediate
prefix + , (comma)
Rename the current window
Basic

Pane(6)

CommandLevel
prefix + "%"
Split the current pane vertically (left/right)
Basic
prefix + '"'
Split the current pane horizontally (top/bottom)
Basic
prefix + arrow keys
Navigate to the adjacent pane by direction
Basic
prefix + o
Cycle to the next pane
Basic
prefix + z
Toggle pane zoom (fullscreen/restore)
Basic
prefix + Ctrl+arrow
Resize pane by 1 unit in the given direction
Intermediate

Layout(3)

CommandLevel
prefix + space
Cycle through all pane layouts
Basic
prefix + M-1 / M-2 / M-3 / M-4 / M-5
Select predefined layout (even-horizontal/even-vertical/main-horizontal/main-vertical/tiled)
Intermediate
:setw synchronize-panes on
Synchronize input across all panes
Expert

Config(9)

CommandLevel
set -g prefix C-a
Change default prefix from Ctrl+b to Ctrl+a
Intermediate
set -g mouse on
Enable mouse support (click/drag/scroll)
Basic
set -g default-terminal "screen-256color"
Set terminal type for 256-color support
Intermediate
set -g status-interval 5
Set status bar refresh interval in seconds
Intermediate
set -g history-limit 50000
Set maximum scrollback history lines per pane
Intermediate
setw -g mode-keys vi
Use vi-style key bindings in copy mode
Intermediate
bind r source-file ~/.tmux.conf
Bind key to reload tmux configuration (prefix + r)
Intermediate
set -g status-left "#[fg=green]Session: #S"
Customize status bar left content (session name, etc.)
Expert
set -g status-right "#[fg=yellow]%Y-%m-%d %H:%M"
Customize status bar right content (date, time, etc.)
Expert

Clipboard(10)

CommandLevel
prefix + [
Enter copy mode to scroll through history
Intermediate
prefix + ]
Paste content from Tmux buffer
Basic
Space / Enter
Start selection / copy selected text in copy mode
Intermediate
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
Bind vi-style y key to copy selection and exit copy mode
Expert
bind -T copy-mode-vi v send-keys -X begin-selection
Bind vi-style v key to begin text selection
Expert
:capture-pane -S -
Capture the entire pane content to buffer
Intermediate
:show-buffer
Display current buffer contents
Intermediate
:list-buffers
List all Tmux buffers
Intermediate
:save-buffer <file>
Save buffer contents to a file
Intermediate
:clear-history
Clear the current pane scrollback history
Intermediate

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-16.