Skip to content

Essential tmux Commands for Terminal Multiplexing

tmux is a terminal multiplexer that allows you to manage multiple terminal sessions within a single window. In the past I've used it infrequently, mainly for the purpose of parallel SSH sessions execution, and have pretty much been a multiple-tabs-boi. But recently I've been starting doing a lot of parallel agentic coding, and the characteristics of the work push me into the orbit of tmux-verse.

This article covers the essential commands and configurations I use, I will update it as I learn more.

Configuration

A minimal .tmux.conf configuration for improved usability:

set -g mouse on
set -g set-clipboard on

This configuration enables mouse support for scrolling and selecting panes, and integrates with the system clipboard for seamless copy-paste operations.

Session Management

Basic Session Operations

The fundamental commands for working with tmux sessions:

# Start a new tmux session
tmux

# Detach from current session (leaves it running in background)
Ctrl + b + d

# Reattach to the last session
tmux a

Named Sessions

For better organization when working with multiple sessions:

# Create a named session
tmux new -s <session-name>

# List all sessions
tmux ls

# Attach to a specific named session
tmux a -t <session-name>

# Terminate a specific session
tmux kill-session -t <session-name>

# Terminate all tmux sessions
tmux kill-server

Window Management

Windows are tabs within a tmux session. Each window can contain multiple panes.

# Create a new window
Ctrl + b + c

# Navigate to a specific window by number (0-9)
Ctrl + b + <window-number>

# Navigate to the next window
Ctrl + b + n

# Navigate to the previous window
Ctrl + b + p

Pane Management

Panes allow you to split windows into multiple sections, each running its own shell.

Creating and Navigating Panes

# Split window vertically (creates left/right panes)
Ctrl + b + %

# Split window horizontally (creates top/bottom panes)
Ctrl + b + "

# Navigate between panes using arrow keys
Ctrl + b + [arrow key]

Resizing Panes

With mouse support enabled in the configuration, you can resize panes by dragging the pane borders with your mouse. Simply click and drag the divider between panes to adjust their size.

For keyboard-based resizing, use command mode instead of remapping arrow keys on macOS:

# Enter command mode
Ctrl + b

# Resize commands (optional size in cells)
:resize-pane -D <size>  # Resize down
:resize-pane -U <size>  # Resize up
:resize-pane -L <size>  # Resize left
:resize-pane -R <size>  # Resize right

Synchronized Panes

Execute the same command across multiple panes simultaneously:

# Toggle synchronized input across all panes
Ctrl + b
:setw synchronize-panes

This feature is particularly useful when managing multiple servers or running the same commands in different environments.

Copy Mode

Copy mode allows you to scroll through terminal output and copy text.

Basic Copy Operations

# Enter copy mode
Ctrl + b + [

# Exit copy mode
Ctrl + c  # or press 'q'

In copy mode, you can: - Scroll using arrow keys or mouse wheel - Copy text using mouse selection (drag and drop)

Keyboard-based Selection with vi Mode

For keyboard-driven text selection:

# Enable vi key bindings
Ctrl + b
:setw -g mode-keys vi

With vi mode enabled: 1. Enter copy mode with Ctrl + b + [ 2. Navigate to the start of desired text using vi movement keys 3. Press Space to begin selection 4. Move to the end of desired text 5. Press Enter to copy to clipboard

tmux transforms terminal workflow by enabling persistent, organized, and efficient session management. These essential commands provide a solid foundation for leveraging tmux's capabilities in daily development work.