---
title: "Tmux"
lang: "en"
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/tmux
---

[Home](/)›[Cheatsheets](/cheatsheets)

Cheatsheets

# Tmux

Tmux is a terminal multiplexer for managing multiple terminal sessions, windows, and panes within a single screen. Commands for session, window, and pane management.

7 Categories20 Sections39 ExamplesPublished: 01 Jan 2023Updated: 28 Feb 2025

TmuxTerminal MultiplexerSessionsWindowsPanesDevelopment Tools

[Markdown for AI(opens in a new tab)](/tmux/index.md "Open the plain-Markdown version of this page, for pasting into an AI tool")

Series

[Developer Environment & Tooling](/series/developer-environment--tooling)3/6

[PreviousScreen](/cheatsheets/screen)[NextVim](/cheatsheets/vim)

All posts in this series (6)

Cheatsheets6

1.  [Git](/cheatsheets/git)
2.  [Screen](/cheatsheets/screen)
3.  [TmuxYou are here](/cheatsheets/tmux)
4.  [Vim](/cheatsheets/vim)
5.  [VS Code](/cheatsheets/vscode)
6.  [Python Virtual Environments Cheatsheet](/cheatsheets/python-venv)

Tmux is a terminal multiplexer for managing multiple terminal sessions, windows, and panes within a single screen. This cheatsheet covers the commands, keybindings, and configuration options for everyday tmux usage.

## [Quick start](#quick-start)

Start your first tmux session with a single command:

Terminal window

```
tmux new -s development
```

Then detach with `C-b d` and reattach from anywhere with:

Terminal window

```
tmux attach -t development
```

## [Key concepts](#key-concepts)

**Sessions**: Independent workspaces that continue running even if you disconnect. Useful for keeping servers and processes running.

**Windows**: Tabs within a session. Each window is a full terminal with its own working directory and history.

**Panes**: Splits within a window. Allows multiple shells side-by-side without opening new windows.

## [Essential keybindings](#essential-keybindings)

All keybindings use the prefix key `C-b` (Ctrl+B) unless configured otherwise:

-   `C-b c` - Create new window
-   `C-b n` / `C-b p` - Next/previous window
-   `C-b %` / `C-b "` - Split vertical/horizontal
-   `C-b h/j/k/l` - Navigate panes (requires vim-style config)
-   `C-b [` - Enter scroll/copy mode
-   `C-b d` - Detach from session
-   `C-b ?` - List all keybindings
-   `C-b :` - Enter command mode

## [Popular configuration](#popular-configuration)

For vim-style navigation and mouse support, add to `~/.tmux.conf`:

Terminal window

```
# Enable 256 color supportset -g default-terminal "screen-256color"set -ga terminal-overrides ",xterm-256color:RGB"
# Enable mouseset -g mouse on
# Use vim keys for navigationsetw -g mode-keys vibind h select-pane -Lbind j select-pane -Dbind k select-pane -Ubind l select-pane -R
# Resize panes with vim keysbind H resize-pane -L 5bind J resize-pane -D 5bind K resize-pane -U 5bind L resize-pane -R 5
# Increase history limitset -g history-limit 50000
# Reload configbind r source-file ~/.tmux.conf
```

Then reload with `C-b :` and type `source-file ~/.tmux.conf`.

## [Tips for productivity](#tips-for-productivity)

1.  **Use Named Sessions**: `tmux new -s work` is easier to remember than session numbers
2.  **Create Window Groups**: Organize windows logically within sessions (editor, server, testing)
3.  **Pair Programming**: Multiple users can attach to the same session at once
4.  **Automation**: Use `tmux send-keys` in scripts to automate setup and testing
5.  **Mouse Support**: Enable `set -g mouse on` to scroll and select panes with the mouse

## [Resources](#resources)

-   Official Tmux Manual: [https://linux.die.net/man/1/tmux](https://linux.die.net/man/1/tmux)
-   GitHub Repository: [https://github.com/tmux/tmux](https://github.com/tmux/tmux)
-   Community Wiki: [https://github.com/tmux/tmux/wiki](https://github.com/tmux/tmux/wiki)

[Getting Started](#category-getting-started)

-   [Starting Tmux](#section-starting-tmux)
-   [Basic Concepts](#section-basic-concepts)
-   [Help and Command Mode](#section-help-and-command-mode)

[Sessions](#category-sessions)

-   [Create and Attach Sessions](#section-session-creation-attachment)
-   [Session Switching and Management](#section-session-management)
-   [Detach and Reattach](#section-detach-and-reattach)

[Windows](#category-windows)

-   [Create and Navigate Windows](#section-window-creation)
-   [Manage and Rename Windows](#section-window-management)
-   [Window Selection and Monitoring](#section-window-selection)

[Panes](#category-panes)

-   [Split Panes Vertically and Horizontally](#section-pane-splitting)
-   [Navigate and Resize Panes](#section-pane-navigation-resize)
-   [Close and Manage Panes](#section-pane-manipulation)

[Copy/Paste & Scrolling](#category-copypaste-scrolling)

-   [Enter Scroll Mode and Navigate Buffer](#section-scroll-mode-buffer)
-   [Copy and Paste Text](#section-copy-paste-operations)
-   [Search in Buffer History](#section-search-in-buffer)

[Keybindings & Commands](#category-keybindings-commands)

-   [Essential Keybindings Reference](#section-common-keybindings)
-   [Command Mode and Advanced Usage](#section-command-mode-advanced)

[Configuration & Customization](#category-configuration-customization)

-   [Tmux Configuration File Basics](#section-tmux-conf-basics)
-   [Customize Status Line](#section-statusline-customization)
-   [Colors and Styling](#section-colors-styling)

No commands found

Try adjusting your search term

## Getting Started

Start using tmux and learn basic concepts

### Starting Tmux

Launch tmux and create your first session

#### Accessibility

Clear examples of starting tmux with different modes

#### Best Practices

-   Use descriptive session names like 'work', 'dev', 'personal'
-   Create sessions detached for automated workflows
-   Use UTF8 flag if dealing with international characters

#### Common Errors

-   **sessions already exist:** Use tmux attach to connect to existing session instead

#### Keywords

startlaunchtmuxnewsession

[Learn more](https://linux.die.net/man/1/tmux)

#### Start tmux without session name

Launches tmux and creates a new default session (session 0).

Code

Terminal window

```
# Start a tmux sessiontmux
# Start tmux with UTF8 supporttmux -u
# Start with specific sockettmux -S ~/.tmux.socket
```

Execution

Terminal window

```
tmux
```

Output

Terminal window

```
[new session created]
```

-   Useful for quick sessions you don't plan to keep
-   Creates session with numeric identifier
-   Can reattach with tmux attach

#### Create named session

Creates a new named tmux session for better organization and easy identification.

Code

Terminal window

```
# Create new session with specific nametmux new -s mysession
# Create named session detachedtmux new -s work -d
# Create with shell commandtmux new -s dev -d "cd ~/projects && bash"
```

Execution

Terminal window

```
tmux new -s development
```

Output

Terminal window

```
[new session created - development]
```

-   Named sessions are easier to manage than numbered
-   \-d flag starts session detached (background)
-   Can start in specific directory with shell commands

### Basic Concepts

Understand tmux structure and terminology

#### Accessibility

Visual explanation of tmux's hierarchical structure

#### Best Practices

-   Understand session/window/pane relationship
-   Use sessions for different projects
-   Use windows for different tasks within project
-   Use panes for side-by-side related work

#### Common Errors

-   **no server running:** Sessions don't exist yet; start a new one with tmux new

#### Keywords

sessionswindowspanesstructurehierarchy

[Learn more](https://github.com/tmux/tmux/wiki)

#### Understanding session, window, and pane hierarchy

Tmux organizes screen space into sessions containing windows, which contain panes.

Code

```
1Session (development)2├── Window 0 (editor)3│   ├── Pane 0 (active)4│   └── Pane 15├── Window 1 (terminal)6│   └── Pane 07└── Window 2 (build)8    ├── Pane 09    ├── Pane 110    └── Pane 2
```

Execution

Terminal window

```
tmux list-sessions && tmux list-windows
```

Output

Terminal window

```
development: 2 windows0: editor- (2 panes)1: terminal- (1 pane)
```

-   Session contains multiple windows
-   Window contains multiple panes
-   Each pane is a separate terminal shell

#### Check tmux server status

View active sessions and tmux configuration details.

Code

Terminal window

```
# List all sessionstmux ls
# Get detailed session infotmux info
# Show versiontmux -V
```

Execution

Terminal window

```
tmux ls
```

Output

Terminal window

```
development: 2 windows (80x24)work: 1 window (120x30)
```

-   Useful for checking what's running before attaching
-   Shows terminal dimensions for each session

### Help and Command Mode

Access built-in help and run commands

#### Accessibility

Clear navigation through help system

#### Best Practices

-   Learn core keybindings first
-   Use ? for quick reference during work
-   Explore tmux man page for advanced features

#### Common Errors

-   **unknown command:** Check keybinding with tmux list-keys

#### Keywords

helpcommandkeybindingsreference

[Learn more](https://linux.die.net/man/1/tmux)

#### Access help and keybindings

Access the full help system and keybinding references within tmux.

Code

Terminal window

```
# Display keybindings help (in tmux)C-b ?
# Enter command modeC-b :
# List keybindings from shelltmux list-keys
# List all commandstmux list-commands
```

Execution

Terminal window

```
tmux list-keys | head -20
```

Output

Terminal window

```
bind-key -T prefix C-b send-keys -X send-prefixbind-key -T prefix C-c new-windowbind-key -T prefix C-d detach-client
```

-   C-b is the default prefix key
-   Command mode allows advanced operations
-   ? and : are the keys to remember for discoverability

#### Run commands and display help

Display tmux configuration and useful information overlays.

Code

Terminal window

```
# In tmux, run command to show messageC-b :
# Display clock in sessionC-b t
# Show pane numbersC-b q
# Exit help or clock press any key
```

Execution

Terminal window

```
tmux show-options -g
```

Output

Terminal window

```
aggressive-resize offallow-same-window onbase-index 0bell-action any
```

-   \[object Object\]
-   \[object Object\]
-   Exit overlays with any key or Escape

## Sessions

Work with tmux sessions for isolated workspaces

### Create and Attach Sessions

Create new sessions and attach to existing ones

#### Accessibility

Clear distinction between new, attach, and detach operations

#### Best Practices

-   Create session for each major project
-   Detach before closing terminal (C-b d)
-   Use descriptive names for easy recall

#### Common Errors

-   **session not found:** Use tmux ls to see available sessions

#### Keywords

newattachsessioncreateconnect

[Learn more](https://linux.die.net/man/1/tmux)

#### Create and attach to new session

Creates a new named session and attaches immediately unless using -d flag.

Code

Terminal window

```
# Create new session with default nametmux new -s mysession
# Create session in background (detached)tmux new -s background -d
# Create session and run commandtmux new -s nodejs -d "node server.js"
# Create with specific working directorytmux new -s project -d -c ~/projects/myapp
```

Execution

Terminal window

```
tmux new -s devwork
```

Output

Terminal window

```
[new session created - devwork]
```

-   Without -d, you're immediately attached to the new session
-   \-d useful for automation and batch operations
-   \-c sets initial working directory

#### Attach to existing session

Connects to an existing session, restoring the full terminal state.

Code

Terminal window

```
# Attach to session by nametmux attach -t mysession
# Attach to last sessiontmux attach
# Attach to session by numbertmux attach -t 0
# Attach read-onlytmux attach -t session -r
```

Execution

Terminal window

```
tmux attach -t development
```

Output

Terminal window

```
[attached to development session]
```

-   Must use exact session name or number
-   \-r flag makes it read-only (no input)
-   Default is most recently used session

### Session Switching and Management

Switch between sessions and manage multiple sessions

#### Accessibility

Clear processes for switching and managing sessions

#### Best Practices

-   Regularly list sessions to stay organized
-   Rename sessions to reflect current state
-   Kill unused sessions to reduce server memory

#### Common Errors

-   **can't find session:** Verify session name exists with tmux ls

#### Keywords

switchlistrenamekilldetach

[Learn more](https://linux.die.net/man/1/tmux)

#### Switch between sessions

Quickly switch between different sessions from command line or interactively.

Code

Terminal window

```
# Switch to named sessiontmux switch -t mysession
# From inside tmux, cycle through sessionsC-b (    # Previous sessionC-b )    # Next session
# List and select session interactivelytmux choose-session
```

Execution

Terminal window

```
tmux switch -t work
```

Output

Terminal window

```
[switched to work session]
```

-   C-b ( and ) cycle through open sessions
-   Useful for toggling between two sessions

#### List and manage sessions

View all active sessions, rename, and remove sessions as needed.

Code

Terminal window

```
# List all sessionstmux ls# ortmux list-sessions
# Rename sessiontmux rename-session -t old newname
# Kill specific sessiontmux kill-session -t sessionname
# Kill all sessions except currenttmux kill-session -t '!^'
```

Execution

Terminal window

```
tmux ls
```

Output

Terminal window

```
development: 3 windowswork: 2 windowstesting: 1 window (current)
```

-   Sessions persist until explicitly killed or tmux server stops
-   Renaming helps organize long-running sessions
-   Kill-session useful for cleanup after pairing sessions

### Detach and Reattach

Detach from sessions and manage disconnections

#### Accessibility

Clear explanation of detach/reattach workflow

#### Best Practices

-   Always detach instead of killing terminal
-   Reattach from another terminal to recover work
-   Use detach to switch between local and remote work

#### Common Errors

-   **can't attach from multiple locations:** Sessions do attach from multiple clients by design, but resize may differ

#### Keywords

detachconnectionbackgroundreattach

[Learn more](https://linux.die.net/man/1/tmux)

#### Detach from session

Safely detach from session, keeping it running in background.

Code

Terminal window

```
# Detach from current session (in tmux)C-b d
# Force detach all clients except specifiedtmux detach-client -t session -a
# Detach all clients from all sessionstmux kill-server
```

Execution

Terminal window

```
tmux detach-client -t development
```

Output

Terminal window

```
[detached from development]
```

-   C-b d is most common way to detach
-   Session continues running after detach
-   Useful for keeping processes running over SSH

#### Manage connections and windows

View client connections and session metadata.

Code

Terminal window

```
# List all clients connected to sessiontmux list-clients
# Details about specific sessiontmux display-message -t session -p
# Show session activitytmux list-clients -t session
```

Execution

Terminal window

```
tmux list-clients
```

Output

Terminal window

```
/dev/pts/0: 0 (80 x 24) [UTF8]/dev/pts/1: 1 (120 x 30) [UTF8]
```

-   Multiple clients can be attached to same session
-   Useful for pair programming
-   Different connections can have different window sizes

## Windows

Manage multiple windows within a tmux session

### Create and Navigate Windows

Create new windows and move between them

#### Accessibility

Clear keybinding reference for window navigation

#### Best Practices

-   Use descriptive window names
-   Create windows for different tasks (editor, server, test)
-   Use number keys for frequent windows

#### Common Errors

-   **window doesn't exist:** Create window first with C-b c or use list-windows to check

#### Keywords

new-windowwindowscnpnavigate

[Learn more](https://linux.die.net/man/1/tmux)

#### Create new window

Creates new window in current or specified session and switches to it.

Code

Terminal window

```
# Create new window (in tmux)C-b c
# Create window with nameC-b : new-window -n editor
# Create window and run commandtmux new-window -t session:1 -n server "npm start"
# Create before current windowC-b : new-window -b -n name
```

Execution

Terminal window

```
tmux new-window -t development -n editor
```

Output

Terminal window

```
[new window created: editor]
```

-   C-b c is fastest way to create window
-   Windows appear as numbered tabs at bottom
-   Each window is independent shell environment

#### Navigate windows

Navigate between windows using keybindings or command line.

Code

Terminal window

```
# Go to next windowC-b n
# Go to previous windowC-b p
# Go to specific window by number (0-9)C-b 0    # Go to window 0C-b 1    # Go to window 1
# Go to last active windowC-b l
# List windows and selectC-b w
```

Execution

Terminal window

```
tmux select-window -t development:1
```

Output

Terminal window

```
[switched to window 1]
```

-   C-b n and p cover most everyday window switching
-   Number keys 0-9 jump directly to window
-   C-b l toggles between two most recent windows

### Manage and Rename Windows

Rename, move, and organize windows

#### Accessibility

Clear commands for window manipulation

#### Best Practices

-   Keep window count manageable (5-7 windows)
-   Rename windows to their purpose
-   Close unused windows to reduce clutter

#### Common Errors

-   **can't kill last window:** Create new window first before killing last one

#### Keywords

renamemoveswapkillwindow

[Learn more](https://linux.die.net/man/1/tmux)

#### Rename and reorder windows

Rename windows for better organization and flexibility.

Code

Terminal window

```
# Rename current window (in tmux)C-b ,
# Rename window via commandtmux rename-window -t session:0 newname
# Move window to different positiontmux move-window -t session:0 -s session:1
# Swap windowstmux swap-window -t session:0 -s session:1
```

Execution

Terminal window

```
tmux rename-window -t development:0 editor
```

Output

Terminal window

```
[window renamed from 0 to editor]
```

-   C-b , is quick rename within tmux
-   Renaming is visual only, doesn't affect functionality
-   Useful for distinguishing similar windows

#### List and close windows

View window list, details, and close windows when no longer needed.

Code

Terminal window

```
# List windows in sessiontmux list-windows -t session
# Get detailed window infotmux display-message -t session -p "#{window_name}"
# Kill current window (in tmux)C-b &
# Kill specific windowtmux kill-window -t session:0
```

Execution

Terminal window

```
tmux list-windows -t development
```

Output

Terminal window

```
0: editor* (2 panes) [80x24]1: server (1 pane) [80x24]2: test (1 pane) [80x24]
```

-   C-b & kills current window with confirmation
-   Asterisk (\*) indicates active window
-   Closing last window closes session

### Window Selection and Monitoring

Select windows and monitor activity

#### Accessibility

Interactive methods for selecting windows

#### Best Practices

-   Use window activity monitoring for servers
-   Set meaningful window names to identify at a glance
-   Monitor important windows during pairing sessions

#### Common Errors

-   **activity monitoring not showing:** Enable with set-window-option monitor-activity on

#### Keywords

selectactivitymonitorliststatus

[Learn more](https://linux.die.net/man/1/tmux)

#### Use window list and selection menu

Interactively select windows or monitor them for activity.

Code

Terminal window

```
# Show window list menu (in tmux)C-b w
# Choose window interactivelytmux choose-window
# Monitor window for activitytmux set-window-option -t session:0 monitor-activity on
# Show window activity in status bartmux set-window-option -t session monitor-silence 30
```

Execution

Terminal window

```
tmux choose-window
```

Output

Terminal window

```
(0) editor(1) server*(2) test
```

-   C-b w shows window list with arrow navigation
-   Space or Enter selects window
-   Monitor activity useful for long-running processes

## Panes

Split and manage panes within windows

### Split Panes Vertically and Horizontally

Create pane layouts and split orientations

#### Accessibility

Clear visual reference for split directions

#### Best Practices

-   Split for related tasks (editor + server output)
-   Keep splits to 2-3 panes for readability
-   Use layouts to organize complex window structures

#### Common Errors

-   **panes too small:** Resize with C-b HJKL or adjust split percentage

#### Keywords

splitpaneverticalhorizontallayout

[Learn more](https://linux.die.net/man/1/tmux)

#### Split panes vertically and horizontally

Create side-by-side (vertical) or stacked (horizontal) pane layouts.

Code

Terminal window

```
# Split current pane vertically (left-right)C-b %
# Split current pane horizontally (top-bottom)C-b "
# Split vertically with commandtmux split-window -h -t session:0 "top"
# Split horizontally with specific sizetmux split-window -v -t session:0 -l 10
```

Execution

Terminal window

```
tmux split-window -h
```

Output

Terminal window

```
[pane 0 and 1 created]
```

-   C-b % for vertical split (new pane on right)
-   C-b " for horizontal split (new pane below)
-   Splits are always of current pane

#### Create complex pane layouts

Use preset layouts or create complex splits through scripting.

Code

Terminal window

```
# Display preset layoutsC-b Space    # Cycle through layouts
# Pre-defined layouts# even-horizontal, even-vertical, main-horizontal# main-vertical, tiledtmux select-layout -t session:0 main-horizontal
# Create custom split scripttmux new-window -t session \  && tmux split-window -h \  && tmux split-window -v -p 25
```

Execution

Terminal window

```
tmux select-layout even-horizontal
```

Output

Terminal window

```
[layout changed to even-horizontal]
```

-   C-b Space cycles through available layouts
-   Layouts auto-arrange panes
-   Keeps window setups consistent across sessions

### Navigate and Resize Panes

Move focus between panes and resize them

#### Accessibility

Intuitive vim-like navigation for pane movement

#### Best Practices

-   Use vim navigation for consistency with editor
-   Resize panes to focus on most important content
-   Keep working pane visible and readable

#### Common Errors

-   **h/j/k/l keys not working:** Configure vim-style bindings in tmux.conf

#### Keywords

navigatemoveresizefocushjkl

[Learn more](https://linux.die.net/man/1/tmux)

#### Navigate between panes

Navigate between panes using vim-like keybindings or direct selection.

Code

Terminal window

```
# Move to pane in direction (vim-like navigation)C-b h    # Move leftC-b j    # Move downC-b k    # Move upC-b l    # Move right
# Cycle through panesC-b o    # Go to next paneC-b ;    # Go to previously active pane
# Select pane by numberC-b q    # Show pane numbers then press number
```

Execution

Terminal window

```
tmux select-pane -t session:0.1
```

Output

Terminal window

```
[focused on pane 1]
```

-   Requires vim-style navigation setup
-   Default keys might be different without config
-   C-b q shows pane numbers for direct access

#### Resize panes

Adjust pane sizes to focus on important areas.

Code

Terminal window

```
# Resize pane in direction (uppercase HJKL)C-b H    # Resize leftC-b J    # Resize downC-b K    # Resize upC-b L    # Resize right
# Resize with command linetmux resize-pane -t session:0.0 -U 5  # Up 5 linestmux resize-pane -t session:0.0 -R 10 # Right 10 cols
# Make equal sizeC-b =    # Distribute panes evenly
```

Execution

Terminal window

```
tmux resize-pane -t development:0.0 -U 10
```

Output

Terminal window

```
[pane resized]
```

-   Requires vim-style bindings setup
-   C-b = distributes space evenly
-   Useful for comparing output side-by-side

### Close and Manage Panes

Remove, move, and organize panes

#### Accessibility

Multiple methods for pane removal and manipulation

#### Best Practices

-   Close panes instead of windows for minor changes
-   Use break-pane to promote pane to window
-   Keep pane count under 10 for manageability

#### Common Errors

-   **can't close last pane:** Close window instead with C-b &

#### Keywords

closekillbreakjoinswappane

[Learn more](https://linux.die.net/man/1/tmux)

#### Close and remove panes

Remove panes or reorganize them across windows.

Code

Terminal window

```
# Close current pane (in tmux)C-b x      # Kill pane with confirmation
# Kill pane via commandtmux kill-pane -t session:0.0
# Break pane into new windowC-b !
# Join pane from another windowtmux join-pane -s session:0.0 -t session:1
```

Execution

Terminal window

```
tmux kill-pane -t development:0.1
```

Output

Terminal window

```
[pane 1 closed]
```

-   C-b x offers confirmation before killing
-   Breaking pane creates new window from it
-   Joining pane combines windows

#### Swap and manage pane layout

Reorganize pane positions within a window layout.

Code

Terminal window

```
# Swap current pane with nextC-b {    # Move pane leftC-b }    # Move pane right
# Swap specific panestmux swap-pane -t session:0.0 -s session:0.1
# Show pane layouttmux display-message -t session:0 -p "#{window_layout}"
```

Execution

Terminal window

```
tmux swap-pane -t development:0.0 -s development:0.1
```

Output

Terminal window

```
[panes swapped]
```

-   C-b { and } change pane order visually
-   Useful for reordering without closing

## Copy/Paste & Scrolling

Manage text copying, pasting, and buffer navigation

### Enter Scroll Mode and Navigate Buffer

Access and scroll through text history

#### Accessibility

Clear step-by-step process for text selection

#### Best Practices

-   Use mouse for quick text selection
-   Learn keyboard navigation for scripting
-   Switch between mouse and keyboard depending on the task

#### Common Errors

-   **mouse selection not working:** Enable with 'set -g mouse on' in tmux.conf

#### Keywords

scrollbufferhistorynavigationtext

[Learn more](https://linux.die.net/man/1/tmux)

#### Enter scroll mode and navigate

Enter scroll mode to view terminal history and select text.

Code

Terminal window

```
# Enter scroll/copy mode (in tmux)C-b [
# Navigate while in scroll modeArrow keys          # Move up/down/left/rightPage Up/Page Down   # Scroll by pageHome/End            # Jump to start/endg/G                 # Jump to beginning/end
# Exit scroll modeq                   # Quit scroll mode
```

Execution

Terminal window

```
tmux send-keys -t session 'C-b' '['
```

Output

Terminal window

```
[scroll mode activated - use arrows to navigate]
```

-   C-b \[ enters scroll/copy mode for viewing history
-   Once in mode, use vi keys (hjkl) or arrows to navigate
-   ESC or q exits without copying

#### Enable mouse support for scrolling

Enable mouse support for modern terminal interaction and scrolling.

Code

Terminal window

```
# Enable mouse support in tmux.confset -g mouse on
# With mouse enabled:Scroll wheel          # Scroll up/downClick and drag        # Select text (auto-copies)Middle click          # Paste selectedRight click           # Show context menu
# Disable mouse for specific sessiontmux set -t session mouse off
```

Execution

Terminal window

```
tmux set -g mouse on
```

Output

Terminal window

```
mouse on
```

-   Mouse mode makes tmux more intuitive for newcomers
-   Can toggle per session or globally
-   Click-to-select is faster than keyboard

### Copy and Paste Text

Select, copy, and paste text between panes

#### Accessibility

Clear step-by-step process for copy-paste workflow

#### Best Practices

-   Use Space and Enter for quick copy-paste
-   Check buffers if paste doesn't show expected text
-   Clear old buffers to preserve memory

#### Common Errors

-   **pasted wrong text:** Check buffer list with tmux list-buffers

#### Keywords

copypasteselectionbufferclipboard

[Learn more](https://linux.die.net/man/1/tmux)

#### Copy text in scroll mode

Select text in scroll mode and copy for pasting elsewhere.

Code

Terminal window

```
# Enter scroll modeC-b [
# Position cursor and start selectionSpace               # Start selection at cursor
# Move to end of text (vim navigation or arrows)Move with h/j/k/l or arrows
# Copy selectionEnter               # Copy and exit mode
# Paste copied text (in tmux)C-b ]
```

Execution

Terminal window

```
echo 'Copy mode workflow'
```

Output

Terminal window

```
Copy mode workflow
```

-   Space starts selection, Enter copies and exits
-   Works across panes and windows
-   Copied text stays in tmux buffer

#### Paste and manage buffers

Store multiple copied items and paste from specific buffers.

Code

Terminal window

```
# Paste from buffer (in tmux)C-b ]
# List all bufferstmux list-buffers
# Show specific buffertmux show-buffer -b buffer-id
# Paste specific buffertmux paste-buffer -b buffer-id
# Clear all bufferstmux delete-buffer -b buffer-id
```

Execution

Terminal window

```
tmux list-buffers
```

Output

Terminal window

```
0: 245 bytes1: 128 bytes2: 512 bytes
```

-   Tmux maintains buffer history
-   Most recent copy is buffer 0
-   Useful for pasting multiple items without re-copying

### Search in Buffer History

Find text within terminal history

#### Accessibility

Intuitive search through terminal output

#### Best Practices

-   Increase history-limit for debugging long processes
-   Use capture-pane to save output for analysis
-   Build search patterns into workflow

#### Common Errors

-   **search not finding text:** Make sure you're in scroll mode, then use C-s for search

#### Keywords

searchfindbufferhistorypattern

[Learn more](https://linux.die.net/man/1/tmux)

#### Search within scroll buffer

Find specific text within terminal output history.

Code

Terminal window

```
# Enter scroll mode firstC-b [
# Start forward searchC-s         # Enter search mode, type pattern
# Start backward searchC-r         # Search backwards
# Navigate search resultsn           # Go to next matchN           # Go to previous match
# Exit searchEscape      # Return to scroll modeq           # Quit scroll mode completely
```

Execution

Terminal window

```
echo 'Search mode: C-b [ then C-s for forward search'
```

Output

Terminal window

```
Search mode active
```

-   C-s for forward search, C-r for backward
-   n and N navigate between matches
-   Case-sensitive by default

#### Search across pane history

Export terminal history or adjust buffer size for longer history.

Code

Terminal window

```
# Capture entire pane history to filetmux capture-pane -t session:0.0 -p > history.txt
# Capture with layouttmux capture-pane -t session:0.0 -p -e > formatted.txt
# Clear historytmux clear-history -t session:0.0
# Set history sizeset -g history-limit 50000
```

Execution

Terminal window

```
tmux capture-pane -t development:0 -p | head -20
```

Output

Terminal window

```
[previous terminal output...][previous terminal output...][previous terminal output...]
```

-   Default history limit is 2000 lines
-   Increase for long-running sessions
-   \-e flag preserves colors in captured output

## Keybindings & Commands

Keybindings and command mode usage

### Essential Keybindings Reference

Most frequently used keybindings for daily work

#### Accessibility

Organized reference table for keybindings

#### Best Practices

-   Memorize the ten core keybindings you use every day
-   Use ? when you forget a keybinding
-   Customize keybindings to match your editor

#### Common Errors

-   **keybinding does nothing:** Make sure prefix (C-b) is shown in terminal or run tmux list-keys

#### Keywords

keybindingsshortcutsprefixcommandsc-b

[Learn more](https://linux.die.net/man/1/tmux)

#### Core session and window keybindings

Quick reference for the tmux keybindings used most often.

Code

```
1SESSION/ATTACH2C-b d           Detach from session3C-b (           Previous session4C-b )           Next session5
6WINDOWS7C-b c           New window8C-b n           Next window9C-b p           Previous window10C-b l           Last active window11C-b w           List windows12C-b ,           Rename window13C-b &           Kill window14
15PANES16C-b %           Split vertical17C-b "           Split horizontal18C-b h/j/k/l     Navigate (vim)19C-b HJKL        Resize (vim)20C-b o           Next pane21C-b x           Kill pane22C-b Space       Cycle layouts23C-b !           Break pane to window24C-b {/}         Move pane left/right
```

Execution

Terminal window

```
tmux list-keys | grep -E 'bind-key.*C-b' | head -20
```

Output

Terminal window

```
bind-key -T prefix c new-windowbind-key -T prefix d detach-clientbind-key -T prefix % split-window -hbind-key -T prefix " split-window -v
```

-   C-b is default prefix (press before each binding)
-   Vim keys (h/j/k/l) available with configuration
-   Numbers 0-9 navigate directly to windows

#### Copy/paste and utility keybindings

Keybindings for text manipulation and information displays.

Code

```
1COPY/PASTE2C-b [           Enter scroll mode3C-b ]           Paste buffer4Space           Start selection5Enter           Copy selection6C-s             Search forward7C-r             Search backward8
9DISPLAY/INFO10C-b ?           List keybindings11C-b :           Enter command mode12C-b t           Display clock13C-b q           Show pane numbers14C-b $           Rename session
```

Execution

Terminal window

```
tmux list-keys -T copy-mode | head -15
```

Output

Terminal window

```
send-keys -X copy-selectionsend-keys -X scroll-upsend-keys -X search-forward
```

-   Some bindings only work in copy mode
-   ? shows help within tmux, useful for discovery
-   t displays clock overlay (press any key to exit)

### Command Mode and Advanced Usage

Enter command mode to run tmux commands directly

#### Accessibility

Clear command syntax with examples

#### Best Practices

-   Learn basic keybindings before command mode
-   Use command mode for one-off operations
-   Move frequent commands to keybindings

#### Common Errors

-   **unknown command:** Check command name with tmux list-commands

#### Keywords

commandmodeadvancedsend-keysbind

[Learn more](https://linux.die.net/man/1/tmux)

#### Access and use command mode

Command mode allows advanced operations like sending keystrokes to panes.

Code

Terminal window

```
# Enter command mode (in tmux)C-b :
# Examples of commandssend-keys -t session:0.0 "ls -la" Enterset -g mouse onbind-key custom-key send-keys "command" Enter
# Get help for commandhelp command-name
# Source configuration filesource ~/.tmux.conf
```

Execution

Terminal window

```
tmux send-keys -t development "pwd" Enter
```

Output

Terminal window

```
/home/user/projects
```

-   send-keys runs commands in specified pane
-   Enter key needed to execute commands sent
-   Useful for automation scripts

#### Bind custom keys and utilities

Customize keybindings and run complex commands through command mode.

Code

Terminal window

```
# List all custom bindingstmux list-keys
# Unbind a keytmux unbind-key name
# Bind custom commandtmux bind-key R "send-keys -t session:0 'reload' Enter"
# Run external command from tmuxC-b :run "external-command"
# Execute tmux session setup scripttmux source-file ~/.tmux/setup.sh
```

Execution

Terminal window

```
tmux list-commands | wc -l
```

Output

Terminal window

```
135
```

-   Hundreds of tmux commands available
-   Custom bindings go in tmux.conf
-   Scripts can automate session setup

## Configuration & Customization

Customize tmux behavior and appearance

### Tmux Configuration File Basics

Set up your tmux.conf for custom settings

#### Accessibility

Clear explanation of configuration file structure

#### Best Practices

-   Keep tmux.conf well-commented
-   Test config changes in separate session first
-   Use reload frequently during setup

#### Common Errors

-   **bad format or unknown command:** Check syntax, use: tmux source-file to see errors

#### Keywords

configconfigurationtmux.confsetoption

[Learn more](https://linux.die.net/man/1/tmux)

#### Create and structure tmux.conf

Create ~/.tmux.conf to customize tmux behavior globally.

Code

~/.tmux.conf

```
# Set default terminal (24-bit color support)set -g default-terminal "screen-256color"set -ga terminal-overrides ",xterm-256color:RGB"
# Set default shellset -g default-shell /bin/bash
# Set base index (0 or 1)set -g base-index 0setw -g pane-base-index 0
# Set history limitset -g history-limit 10000
# Mouse supportset -g mouse on
```

Execution

Terminal window

```
cat ~/.tmux.conf | head -10
```

Output

Terminal window

```
set -g default-terminal "screen-256color"set -ga terminal-overrides ",xterm-256color:RGB"set -g mouse on
```

-   use 'set' for session options, 'setw' for window options
-   \-g flag for global, -t for specific target
-   \-a flag appends/adds to option
-   Loaded on tmux start

#### Reload and apply configuration

Apply configuration changes without restarting tmux server.

Code

Terminal window

```
# Reload configuration (in tmux)C-b : source-file ~/.tmux.conf
# Or from shelltmux source-file ~/.tmux.conf
# Check specific optiontmux show-options -g | grep history
# Show all optionstmux show-options -g
```

Execution

Terminal window

```
tmux source-file ~/.tmux.conf
```

Output

Terminal window

```
[configuration reloaded]
```

-   source-file is safe command to reload
-   Changes apply immediately to new panes/windows
-   Existing panes may need refresh

### Customize Status Line

Configure the bottom-of-window status bar

#### Accessibility

Clear examples of status line formatting

#### Best Practices

-   Keep status line readable with minimal clutter
-   Show key info like host, session, time
-   Use colors sparingly for focus

#### Common Errors

-   **status showing wrong format:** Check syntax with tmux show-options -g

#### Keywords

statusstatuslinebarformatappearance

[Learn more](https://linux.die.net/man/1/tmux)

#### Configure left and right status

Set what the status bar shows on the left and on the right.

Code

Terminal window

```
# Simple status formatset -g status-left "[#S]"set -g status-right "#H | %a %d %b %H:%M"
# Complex left status with colorsset -g status-left "#[bg=blue,fg=white] #S #[default]"
# Add window list in middleset -g status-justify centre
# Window status formattingsetw -g window-status-format "#[fg=white] #I: #W "setw -g window-status-current-format "#[bg=green,fg=black] #I: #W #[default]"
```

Execution

Terminal window

```
tmux show-options -g | grep status
```

Output

Terminal window

```
status onstatus-bg defaultstatus-justify leftstatus-left [#S]status-right #H | %a %d %b %H:%M
```

-   #S = session name, #W = window name
-   #H = hostname, #h = short hostname
-   #I = window index, #P = pane index

#### Add status line variables and colors

Add dynamic information and status indicators to the status bar.

Code

Terminal window

```
# Show git branchset -g status-right '#{pane_current_path} | #(cd #{pane_current_path} && git symbolic-ref --short HEAD 2>/dev/null || echo "no-git")'
# Show battery and timeset -g status-right "#(battery) | %H:%M %d-%b-%y"
# Window activity notificationssetw -g window-status-activity-style "fg=red,bg=default"setw -g monitor-activity on
# Highlight important windowssetw -g window-status-bell-style "fg=yellow,bg=red"
```

Execution

Terminal window

```
tmux show-options -g status-right
```

Output

Terminal window

```
#H | %a %d %b %H:%M
```

-   Use
-   Watch for performance impact of commands
-   Activity monitoring helps find updated windows

### Colors and Styling

Apply colors and text attributes to UI elements

#### Accessibility

Comprehensive reference for color and attribute options

#### Best Practices

-   Use high contrast for readability
-   Limit color palette to 3-4 main colors
-   Test on different terminals

#### Common Errors

-   **colors look wrong or washed out:** Check default-terminal setting, may need 256color or RGB support

#### Keywords

colorsattributesstylingforegroundbackground

[Learn more](https://linux.die.net/man/1/tmux)

#### Apply colors and attributes

Apply color schemes to tmux UI components and text.

Code

Terminal window

```
# Standard colorsset -g status-bg blackset -g status-fg white
# Named colors for windowsetw -g window-status-current-bg greensetw -g window-status-current-fg black
# 256 color palettesetw -g window-status-bg colour234      # Dark graysetw -g window-status-fg colour248      # Light gray
# RGB hex colors (if supported)setw -g pane-border-lines heavysetw -g pane-border-style "fg=#444444"
```

Execution

Terminal window

```
tmux show-options -g status-bg
```

Output

Terminal window

```
status-bg black
```

-   \[object Object\]
-   \[object Object\]
-   \[object Object\]

#### Apply text attributes and combinations

Combine colors with text attributes such as bold and underline.

Code

Terminal window

```
# Text attributes#[bold]          Bold text#[underscore]    Underlined#[italics]       Italics (if terminal supports)#[dim]           Dimmed text#[fg=red]        Red text#[bg=yellow]     Yellow background#[default]       Reset to defaults
# Combinations in status lineset -g status-left "#[fg=white,bg=blue,bold] #S #[default]"setw -g window-status-current-format "#[fg=black,bg=green,bold] #W #[default]"
# For pane stylingsetw -g pane-active-border-fg greensetw -g pane-border-fg colour240
```

Execution

Terminal window

```
echo 'Colors: black, red, green, yellow, blue, magenta, cyan, white'
```

Output

Terminal window

```
Colors list for terminal display
```

-   Always use
-   Test colors in your terminal first (256 vs true color)
-   Some attributes may not work in all terminals

Was this useful?

## Tags

#Tmux#Terminal Multiplexer#Sessions#Windows#Panes#Development Tools

## Share

[Facebook](https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmkabumattar.com%2Fcheatsheets%2Ftmux "Share on Facebook")[Twitter](https://twitter.com/intent/tweet/?text=Tmux&url=https%3A%2F%2Fmkabumattar.com%2Fcheatsheets%2Ftmux "Share on Twitter")[LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fmkabumattar.com%2Fcheatsheets%2Ftmux&title=Tmux&summary=Tmux%20is%20a%20terminal%20multiplexer%20for%20managing%20multiple%20terminal%20sessions%2C%20windows%2C%20and%20panes%20within%20a%20single%20screen.%20Commands%20for%20session%2C%20window%2C%20and%20pane%20management.&source=https://mkabumattar.com "Share on LinkedIn")[WhatsApp](https://wa.me/?text=Tmux%20https%3A%2F%2Fmkabumattar.com%2Fcheatsheets%2Ftmux "Share on WhatsApp")[Telegram](https://t.me/share/url?url=https%3A%2F%2Fmkabumattar.com%2Fcheatsheets%2Ftmux&text=Tmux "Share on Telegram")[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fmkabumattar.com%2Fcheatsheets%2Ftmux&title=Tmux "Share on Reddit")[Hacker News](http://news.ycombinator.com/submitlink?u=https%3A%2F%2Fmkabumattar.com%2Fcheatsheets%2Ftmux&t=Tmux "Share on Hacker News")[Pinterest](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fmkabumattar.com%2Fcheatsheets%2Ftmux&media=&description=Tmux%20is%20a%20terminal%20multiplexer%20for%20managing%20multiple%20terminal%20sessions%2C%20windows%2C%20and%20panes%20within%20a%20single%20screen.%20Commands%20for%20session%2C%20window%2C%20and%20pane%20management. "Share on Pinterest")[Email](<mailto:?subject=Tmux&body=Check out this article: https%3A%2F%2Fmkabumattar.com%2Fcheatsheets%2Ftmux>)

## Comments

## You might also enjoy

More posts on similar topics

## [Screen](/cheatsheets/screen)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   Terminal
-   Screen
-   Tools
-   Development
-   System Administration

Getting started GNU Screen is a terminal multiplexer that gives you:Sessions: Full terminal environments that persist even if you disconnect Windows: Multiple terminals (tabs) within

#Screen#Terminal Multiplexer#Sessions+2 tags

[read more](/cheatsheets/screen)

## [Vim](/cheatsheets/vim)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   Editor
-   Text Editor
-   Terminal
-   Command Line
-   Productivity

Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as "vi" with most UNIX systems. The sections below cover Vim commands, sho

#Editor#Vim#Text Editor+3 tags

[read more](/cheatsheets/vim)

## [Git](/cheatsheets/git)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   Version Control
-   Git
-   SCM
-   Collaboration
-   Development Tools

Git is a distributed version control system. Developers use it to track code changes, collaborate with teams, and manage project history. Most software teams build their workflow around it. Key co

#Git#Version Control#Branches+5 tags

[read more](/cheatsheets/git)

## [Cron](/cheatsheets/cron)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   Terminal
-   System Administration
-   Linux
-   Scheduling
-   Automation
-   Tools

Quick reference Field layout Min Hour Day Month Weekday Command\* /path/to/command ┬ ┬ ┬ ┬ ┬ │ │ │ │ └───── Weekday (0=Sunday,

#Cron#Crontab#Scheduling+3 tags

[read more](/cheatsheets/cron)

## [Netcat](/cheatsheets/nc)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   Terminal
-   Networking
-   Tools
-   System Administration
-   Port Scanning

This netcat cheatsheet covers TCP/UDP connections, file transfers, port scanning, banner grabbing, and advanced network operations.

#Netcat#Nc#Network+4 tags

[read more](/cheatsheets/nc)

## [Netstat](/cheatsheets/netstat)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   Terminal
-   System Administration
-   Linux
-   Networking
-   Tools

This netstat cheatsheet covers six categories, with worked examples and troubleshooting steps in each.

#Netstat#Network#Connections+3 tags

[read more](/cheatsheets/netstat)

6 related posts
