Skip to content
Published on

The Complete Tmux Command Guide: Every Command to 10x Your Productivity with a Terminal Multiplexer

Authors
  • Name
    Twitter

1. Introduction to Tmux

1.1 What Is a Terminal Multiplexer?

A Terminal Multiplexer is a tool that lets you create, split, and switch between multiple virtual terminal sessions within a single terminal screen. Even with just one physical monitor, you can run dozens of terminals simultaneously, switching between them instantly or keeping them running in the background.

Tmux (Terminal Multiplexer) is the most widely used modern tool in this category, developed as open source under the BSD license.

The core problems Tmux solves are:

  • Preventing work loss on SSH disconnection: Sessions persist on the server, so you can resume right where you left off after reconnecting
  • Screen splitting: View code editing, server logs, and test execution simultaneously on one screen
  • Work context switching: Separate sessions per project for instant switching
  • Pair programming: Multiple users connect to the same session for collaboration

1.2 GNU Screen vs Tmux Comparison

Before Tmux, GNU Screen was the leading terminal multiplexer. Here are the key differences between the two tools.

FeatureGNU ScreenTmux
First Release19872007
ArchitectureSingle processClient-server model
Screen SplitHorizontal only by defaultBoth horizontal/vertical by default
ScriptingLimitedPowerful command system
Status BarNone by default, manual setupBuilt-in, highly customizable
Copy ModeBasic modeVi/Emacs key binding options
Plugin EcosystemAlmost noneActive TPM-based ecosystem
MaintenanceSlow updatesActive development
LicenseGPLBSD

In conclusion, Tmux is overwhelmingly the better choice for new projects. Tmux leads in scripting, plugins, and community support across the board.

1.3 Use Cases

Here are the most representative scenarios where Tmux shines.

  1. SSH remote server work: Sessions persist even in unstable network environments
  2. Development environment setup: Place editor + server + logs + tests on one screen
  3. Server monitoring: Simultaneously monitor htop, log tails, and network monitoring
  4. Long-running tasks: Detach builds, data migrations, etc. and go home
  5. Pair programming: Multiple developers connect to the same session for real-time collaboration
  6. CI/CD debugging: Monitor each pipeline stage in separate panes

2. Installation and Basic Concepts

2.1 Installation

Installation methods by operating system:

# Ubuntu / Debian
sudo apt update && sudo apt install -y tmux

# CentOS / RHEL / Rocky Linux
sudo yum install -y tmux
# or
sudo dnf install -y tmux

# macOS (Homebrew)
brew install tmux

# Arch Linux
sudo pacman -S tmux

# Build from source (when you need the latest version)
git clone https://github.com/tmux/tmux.git
cd tmux
sh autogen.sh
./configure && make
sudo make install

Verify installation:

tmux -V
# tmux 3.5a

2.2 Core Hierarchy: Session > Window > Pane

To understand Tmux's architecture, you must grasp three layers.

Tmux Server (background process)
  └── Session (logical work unit)
        ├── Window 0 (similar to tabs)
        │     ├── Pane 0 (split region)
        │     ├── Pane 1
        │     └── Pane 2
        ├── Window 1
        │     ├── Pane 0
        │     └── Pane 1
        └── Window 2
              └── Pane 0
ConceptDescriptionAnalogy
ServerThe Tmux process. Manages all sessionsOperating system
SessionIndependent workspace. Contains multiple WindowsDesktop/workspace
WindowFull screen within a session. Switchable like tabsBrowser tab
PaneIndividual terminal area from splitting a windowScreen split

2.3 Prefix Key Concept

Tmux uses a Prefix Key for all key bindings. The default is Ctrl-b.

How it works:

  1. Press Ctrl-b (press simultaneously then release)
  2. Then press the desired command key

For example, to create a new window:

  1. Press Ctrl-b
  2. Press c

In this document, the Prefix Key is referred to as <prefix>. So <prefix> c means press Ctrl-b then press c.

Tip: If Ctrl-b feels uncomfortable, you can change it to Ctrl-a (Screen style) or Ctrl-Space in .tmux.conf. This is covered in Section 7.


3. Session Management

Sessions are the top-level work unit in Tmux. Manage work contexts by separating sessions per project or purpose.

3.1 Creating Sessions

# Create default session (auto-named: 0, 1, 2, ...)
tmux

# Create session with a name
tmux new -s dev

# Create with name and start in a specific directory
tmux new -s project -c ~/workspace/my-project

# Create session and immediately run a command
tmux new -s monitoring 'htop'

# Create session without attaching (background)
tmux new -s background -d

# Create with window name specified
tmux new -s dev -n editor

3.2 Listing Sessions

# List sessions
tmux ls
# or
tmux list-sessions

# Example output:
# dev: 3 windows (created Mon Mar  1 10:00:00 2026)
# monitoring: 1 windows (created Mon Mar  1 10:05:00 2026)
# background: 2 windows (created Mon Mar  1 10:10:00 2026) (attached)

You can also view the session list from within Tmux.

<prefix> s    # Show session list interactively

3.3 Attaching to Sessions

# Attach to the last used session
tmux attach
# or
tmux a

# Attach to a specific session
tmux attach -t dev
# or
tmux a -t dev

# Force attach even if another client is connected (detaches existing client)
tmux attach -dt dev

3.4 Detaching from Sessions

When you detach from a session, it continues running in the background.

<prefix> d    # Detach from current session
# Detach a specific client (from outside)
tmux detach-client -t dev

3.5 Renaming Sessions

<prefix> $    # Rename current session (prompt appears)
# Rename session from outside
tmux rename-session -t old_name new_name

3.6 Switching Sessions

<prefix> s    # Select and switch from session list
<prefix> (    # Switch to previous session
<prefix> )    # Switch to next session
# Switch to a specific session from outside (when already attached)
tmux switch-client -t monitoring

3.7 Terminating Sessions

# Kill a specific session
tmux kill-session -t dev

# Kill all sessions except the current one
tmux kill-session -a

# Kill all sessions except a specific one
tmux kill-session -a -t dev

# Kill the entire Tmux server (kills all sessions)
tmux kill-server

Terminating from inside a session:

# Exit or Ctrl-d in the last window/pane to close the session
exit

3.8 Practical Session Management Patterns

# Pattern: attach if session exists, create if not
tmux new -A -s dev

# This is equivalent to:
# tmux has-session -t dev 2>/dev/null && tmux attach -t dev || tmux new -s dev

4. Window Management

Windows function like tabs within a session. The window list is displayed in the bottom status bar.

4.1 Creating Windows

<prefix> c    # Create new window
# Create window from command line
tmux new-window

# Create window with a name
tmux new-window -n logs

# Create window in a specific directory
tmux new-window -c ~/workspace/logs -n logs

# Create window at a specific position (index)
tmux new-window -t 3

4.2 Renaming Windows

<prefix> ,    # Rename current window (prompt appears)
# Rename window from command line
tmux rename-window -t 0 editor

Tip: To prevent window names from automatically changing when a shell runs, add the following to .tmux.conf.

set-option -g allow-rename off

4.3 Switching Windows

<prefix> 0~9  # Jump directly to window number (0-9)
<prefix> n    # Move to next window
<prefix> p    # Move to previous window
<prefix> l    # Toggle to last used window
<prefix> w    # Interactively select from window list
<prefix> '    # Enter window index to jump to (useful for 10+)
<prefix> f    # Search by window name to jump

4.4 Moving and Reordering Windows

# Change window order (move current window to position 3)
tmux move-window -t 3

# Move window to another session
tmux move-window -t other_session:

# Move window to specific position in another session
tmux move-window -t other_session:2

# Swap current window with a specific window
tmux swap-window -t 0

# Renumber windows (remove gaps)
tmux move-window -r

4.5 Closing Windows

<prefix> &    # Close current window (confirmation prompt shown)
# Close specific window from command line
tmux kill-window -t 2

# Close all windows except the current one
tmux kill-window -a

4.6 Listing Windows

# List windows across all sessions
tmux list-windows -a

# List windows in a specific session
tmux list-windows -t dev

5. Pane Management

Panes split windows to place multiple terminals on one screen. This is Tmux's most powerful and frequently used feature.

5.1 Splitting Panes

<prefix> %    # Vertical split (left-right)
<prefix> "    # Horizontal split (top-bottom)
# Split panes from command line
tmux split-window          # Horizontal split
tmux split-window -h       # Vertical split

# Split in a specific directory
tmux split-window -h -c ~/workspace

# Split with a specific size (30% of total)
tmux split-window -p 30
tmux split-window -h -p 40

# Split with specific row/column count
tmux split-window -l 10      # 10 rows high
tmux split-window -h -l 40   # 40 columns wide

# Split and run a command
tmux split-window 'tail -f /var/log/syslog'

5.2 Pane Navigation

<prefix> Arrow keys(Up/Down/Left/Right)    # Navigate panes with arrow keys
<prefix> o               # Cycle to next pane
<prefix> ;               # Toggle to last active pane
<prefix> q               # Show pane numbers (press number to jump to that pane)

Tip: If you prefer Vi-style navigation, add the following to .tmux.conf.

bind h select-pane -L    # Left pane
bind j select-pane -D    # Down pane
bind k select-pane -U    # Up pane
bind l select-pane -R    # Right pane

5.3 Resizing Panes

<prefix> Ctrl-Arrow      # Resize by 1 cell
<prefix> Alt-Arrow       # Resize by 5 cells
# Resize from command line
tmux resize-pane -D 5     # Expand down by 5
tmux resize-pane -U 5     # Expand up by 5
tmux resize-pane -L 10    # Expand left by 10
tmux resize-pane -R 10    # Expand right by 10

Tip: Adding Vi-style resize bindings is convenient.

bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

The -r flag means repeat — you can press the key consecutively without prefix for repeated execution.

5.4 Pane Zoom

Expand a specific pane to full screen or restore it to its original size.

<prefix> z    # Toggle current pane zoom (full screen <-> original size)

When zoomed, Z appears next to the window name in the status bar. Very useful when examining logs closely or editing code intensively.

5.5 Moving and Swapping Panes

<prefix> {    # Move current pane to previous position
<prefix> }    # Move current pane to next position
<prefix> Ctrl-o  # Rotate all panes counter-clockwise
<prefix> Alt-o   # Rotate all panes clockwise
# Swap specific panes
tmux swap-pane -s 0 -t 1

# Move pane to another window (join)
tmux join-pane -t :1          # Move current pane to window 1
tmux join-pane -s :2 -t :1    # Move pane from window 2 to window 1

# Break pane into a separate window
<prefix> !    # Break current pane into new window
# Break pane into new window from command line
tmux break-pane
tmux break-pane -t 1    # Break pane 1 into new window

5.6 Layouts

Tmux provides 5 built-in layouts.

<prefix> Space    # Cycle to next layout
<prefix> Alt-1    # even-horizontal (all panes evenly horizontal)
<prefix> Alt-2    # even-vertical (all panes evenly vertical)
<prefix> Alt-3    # main-horizontal (main pane on top, rest on bottom)
<prefix> Alt-4    # main-vertical (main pane on left, rest on right)
<prefix> Alt-5    # tiled (evenly tiled)

Visual representation of each layout:

even-horizontal          even-vertical
+------+------+------+   +------------------+
|      |      |      |   |     Pane 0       |
| P0   | P1   | P2   |   +------------------+
|      |      |      |   |     Pane 1       |
|      |      |      |   +------------------+
+------+------+------+   |     Pane 2       |
                         +------------------+

main-horizontal          main-vertical
+------------------+     +----------+-------+
|     Pane 0       |     |          | P1    |
|    (main)        |     |  Pane 0  +-------+
+--------+---------+     |  (main)  | P2    |
|  P1    |   P2    |     |          +-------+
+--------+---------+     |          | P3    |
                         +----------+-------+

tiled
+---------+---------+
|  P0     |  P1     |
+---------+---------+
|  P2     |  P3     |
+---------+---------+

5.7 Closing Panes

<prefix> x    # Close current pane (confirmation prompt shown)
# Close pane from command line
tmux kill-pane
tmux kill-pane -t 2    # Close pane 2

# Close all panes except the current one
tmux kill-pane -a

Or type exit in the pane or press Ctrl-d to close it.

5.8 Marking/Unmarking Panes

# Mark pane (toggle)
<prefix> m    # Toggle mark on current pane

# Swap marked pane with current pane
tmux swap-pane

6. Copy Mode

Copy mode lets you scroll through, search, and copy terminal output content. It is one of Tmux's hidden powerful features.

6.1 Entering and Exiting Copy Mode

<prefix> [    # Enter copy mode
q             # Exit copy mode (or Esc)

6.2 Vi vs Emacs Key Bindings

Tmux copy mode supports either Vi or Emacs-style key bindings.

# Set Vi mode in .tmux.conf (strongly recommended)
setw -g mode-keys vi

Key navigation keys in Vi mode:

KeyAction
h, j, k, lLeft, down, up, right
wMove to next word
bMove to previous word
0Move to beginning of line
$Move to end of line
gMove to top of buffer
GMove to bottom of buffer
Ctrl-uScroll half page up
Ctrl-dScroll half page down
Ctrl-bScroll full page up
Ctrl-fScroll full page down

You can search for text within copy mode.

/search_term     # Search downward (Vi mode)
?search_term     # Search upward (Vi mode)
n                # Move to next search result
N                # Move to previous search result

In Emacs mode:

Ctrl-s      # Incremental search downward
Ctrl-r      # Incremental search upward

6.4 Text Selection and Copy

Copy flow in Vi mode:

1. <prefix> [          # Enter copy mode
2. Navigate to start point with movement keys
3. Space              # Begin selection
4. Navigate to end point with movement keys
5. Enter              # Copy selection (saved to tmux buffer)
# Add Vi-style copy/paste bindings (.tmux.conf)
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 r send-keys -X rectangle-toggle

With the above settings applied:

KeyAction
vStart text selection (Visual mode)
VStart line-wise selection
rToggle rectangle (block) selection
yCopy selected area

6.5 Paste

<prefix> ]    # Paste tmux buffer contents
# List buffers
tmux list-buffers

# View specific buffer contents
tmux show-buffer -b 0

# Save buffer to file
tmux save-buffer -b 0 ~/buffer.txt

# Load file contents into buffer
tmux load-buffer ~/content.txt

# Delete buffer
tmux delete-buffer -b 0

6.6 Scrollback Buffer Settings

The default scrollback size is 2000 lines. You can increase it if you need more history.

# .tmux.conf
set -g history-limit 50000

Note: A very large scrollback buffer increases memory usage. 50000 lines is a practical upper limit.


7. Key Binding Customization

7.1 Changing the Prefix Key

If Ctrl-b is uncomfortable, you can change it to another key.

# .tmux.conf - Change to Ctrl-a (GNU Screen style)
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Change to Ctrl-Space (recommended)
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix

Tip: Changing to Ctrl-a conflicts with the default shell shortcut for moving to the beginning of the line. In this case, pressing Ctrl-a twice sends the original Ctrl-a.

7.2 Adding Key Bindings (bind-key)

# Basic syntax
bind-key [options] key command
# Shorthand
bind key command

# Bind without Prefix (-n flag)
bind -n M-Left select-pane -L     # Alt-Left to move to left pane
bind -n M-Right select-pane -R    # Alt-Right to move to right pane
bind -n M-Up select-pane -U       # Alt-Up to move to upper pane
bind -n M-Down select-pane -D     # Alt-Down to move to lower pane

# Repeatable bindings (-r flag)
bind -r h resize-pane -L 5
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r l resize-pane -R 5

# Preserve current path on split
bind '"' split-window -v -c "#{pane_current_path}"
bind '%' split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"

7.3 Unbinding Keys (unbind-key)

# Unbind a specific key
unbind-key C-b
# Shorthand
unbind C-b

# Unbind all key bindings (use with caution)
unbind -a

7.4 Viewing Current Key Bindings

<prefix> ?    # Show all key binding list
# View from command line
tmux list-keys
tmux list-keys | grep split    # Filter specific commands

7.5 Useful Custom Binding Examples

# Instantly reload config file
bind r source-file ~/.tmux.conf \; display-message "Config reloaded!"

# More intuitive split keys
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"

# Renumber windows
bind R move-window -r \; display-message "Windows renumbered!"

# Synchronize mode toggle (simultaneous input to all panes)
bind S setw synchronize-panes \; display-message "Sync #{?synchronize-panes,ON,OFF}"

# Session selection shortcut
bind C-s choose-session

# Run lazygit in popup window (tmux 3.2+)
bind g display-popup -E -w 80% -h 80% "lazygit"

# Run htop in popup window
bind t display-popup -E -w 80% -h 80% "htop"

8. .tmux.conf Configuration Guide

The ~/.tmux.conf file is the configuration file automatically loaded when Tmux starts. Through this file, you can customize nearly all Tmux behavior.

# ~/.tmux.conf

# -------------------------------------------------
# Basic Settings
# -------------------------------------------------

# Change Prefix to Ctrl-a
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Start indexes from 1 (0 key is at the far right of keyboard, inconvenient)
set -g base-index 1
setw -g pane-base-index 1

# Renumber windows when closing
set -g renumber-windows on

# History size
set -g history-limit 50000

# Reduce escape time (for Vim users)
set -sg escape-time 0

# Repeat key input wait time
set -g repeat-time 600

# Enable focus events (for Vim/Neovim integration)
set -g focus-events on

# Reload config
bind r source-file ~/.tmux.conf \; display-message "Config reloaded!"

8.2 Mouse Support

# Enable mouse support (tmux 2.1+)
set -g mouse on

# What you can do with the mouse:
# - Click panes to switch focus
# - Drag pane borders to resize
# - Scroll wheel to browse history
# - Drag text to enter copy mode and select

Tip: Enabling the mouse may cause Tmux to intercept the terminal's native text selection. To copy directly to the system clipboard, hold Shift while selecting with the mouse.

8.3 Vi Mode Settings

# Use Vi key bindings in copy mode
setw -g mode-keys vi

# Vi-style copy
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi V send-keys -X select-line
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
bind -T copy-mode-vi r send-keys -X rectangle-toggle
bind -T copy-mode-vi Escape send-keys -X cancel

# Vi mode for status line commands
set -g status-keys vi

8.4 Status Bar Customization

# -------------------------------------------------
# Status Bar Settings
# -------------------------------------------------

# Status bar position (top or bottom)
set -g status-position bottom

# Status bar refresh interval (seconds)
set -g status-interval 5

# Status bar colors
set -g status-style 'bg=#1e1e2e,fg=#cdd6f4'

# Left status bar
set -g status-left-length 50
set -g status-left '#[fg=#1e1e2e,bg=#89b4fa,bold] #S #[fg=#89b4fa,bg=#1e1e2e] '

# Right status bar
set -g status-right-length 100
set -g status-right '#[fg=#585b70]| #[fg=#cdd6f4]%Y-%m-%d #[fg=#585b70]| #[fg=#cdd6f4]%H:%M #[fg=#89b4fa,bg=#1e1e2e]#[fg=#1e1e2e,bg=#89b4fa,bold] #H '

# Current window style
setw -g window-status-current-format '#[fg=#1e1e2e,bg=#a6e3a1,bold] #I:#W#{?window_zoomed_flag, Z,} '

# Inactive window style
setw -g window-status-format '#[fg=#585b70] #I:#W '

# Window list alignment
set -g status-justify left

8.5 Color Settings (256 Color, True Color)

# 256 color support
set -g default-terminal "screen-256color"

# True Color (24-bit) support
set -ga terminal-overrides ",xterm-256color:Tc"
# or for alacritty
set -ga terminal-overrides ",alacritty:Tc"

# Pane border colors
set -g pane-border-style 'fg=#585b70'
set -g pane-active-border-style 'fg=#89b4fa'

# Message style
set -g message-style 'fg=#cdd6f4,bg=#1e1e2e,bold'

# Copy mode highlight color
setw -g mode-style 'fg=#1e1e2e,bg=#f5c2e7,bold'

8.6 Clipboard Integration

Settings to synchronize text copied within Tmux with the system clipboard.

# macOS (pbcopy/pbpaste)
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"

# Linux (xclip)
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"

# Linux (xsel)
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xsel --clipboard --input"

# Linux (wl-copy, Wayland)
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "wl-copy"

# Cross-platform auto-detection
if-shell "uname | grep -q Darwin" {
    bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
} {
    bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
}

8.7 Complete .tmux.conf Example

A complete configuration integrating all recommended settings.

# ===============================================================
# ~/.tmux.conf - Production-Optimized Configuration
# ===============================================================

# --- Prefix -------------------------------------------------------
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# --- Basic Settings -----------------------------------------------
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
set -g history-limit 50000
set -sg escape-time 0
set -g repeat-time 600
set -g focus-events on
set -g mouse on
setw -g mode-keys vi
set -g status-keys vi

# --- Colors -------------------------------------------------------
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"

# --- Key Bindings -------------------------------------------------
# Reload config
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# Intuitive splits (preserve current path)
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
unbind '"'
unbind %

# Vi-style pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Pane resize
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# Alt + arrow for prefix-less pane navigation
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Shift + arrow for window switching
bind -n S-Left previous-window
bind -n S-Right next-window

# Synchronize toggle
bind S setw synchronize-panes \; display "Sync #{?synchronize-panes,ON,OFF}"

# --- Copy Mode ----------------------------------------------------
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi V send-keys -X select-line
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind -T copy-mode-vi r send-keys -X rectangle-toggle

# --- Status Bar ---------------------------------------------------
set -g status-position bottom
set -g status-interval 5
set -g status-style 'bg=#1e1e2e,fg=#cdd6f4'
set -g status-left-length 50
set -g status-left '#[fg=#1e1e2e,bg=#89b4fa,bold] #S #[default] '
set -g status-right '#[fg=#cdd6f4]%Y-%m-%d %H:%M #[fg=#1e1e2e,bg=#89b4fa,bold] #H '
setw -g window-status-current-format '#[fg=#1e1e2e,bg=#a6e3a1,bold] #I:#W#{?window_zoomed_flag, Z,} '
setw -g window-status-format '#[fg=#585b70] #I:#W '

# --- Pane Borders -------------------------------------------------
set -g pane-border-style 'fg=#585b70'
set -g pane-active-border-style 'fg=#89b4fa'

9. Plugins

9.1 TPM (Tmux Plugin Manager)

TPM is the standard tool for managing Tmux plugins.

Installation:

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

Add to .tmux.conf:

# Plugin list
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-yank'

# TPM initialization (must be at the very end of .tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Plugin management keys:

<prefix> I        # Install plugins
<prefix> U        # Update plugins
<prefix> Alt-u    # Remove unused plugins (Uninstall)

9.2 tmux-sensible

A plugin that sets sensible defaults. Applies universally useful settings at once.

set -g @plugin 'tmux-plugins/tmux-sensible'

9.3 tmux-resurrect

A plugin that can save and restore Tmux sessions to the filesystem. Perfectly restores session structure even after system restarts.

set -g @plugin 'tmux-plugins/tmux-resurrect'

# Vim session restoration (optional)
set -g @resurrect-strategy-vim 'session'
# Neovim session restoration (optional)
set -g @resurrect-strategy-nvim 'session'
# Restore pane contents
set -g @resurrect-capture-pane-contents 'on'

Usage:

<prefix> Ctrl-s    # Save session
<prefix> Ctrl-r    # Restore session

9.4 tmux-continuum

A plugin that automates tmux-resurrect's save/restore.

set -g @plugin 'tmux-plugins/tmux-continuum'

# Auto-save every 15 minutes
set -g @continuum-save-interval '15'

# Auto-restore on Tmux server start
set -g @continuum-restore 'on'

# Auto-start Tmux on system boot (macOS)
set -g @continuum-boot 'on'
set -g @continuum-boot-options 'iterm'

9.5 tmux-yank

A plugin that automatically handles system clipboard integration.

set -g @plugin 'tmux-plugins/tmux-yank'

# Keep copy mode after copying (default exits)
set -g @yank_action 'copy-pipe'
PluginDescription
tmux-plugins/tmux-prefix-highlightHighlight status bar when prefix key is pressed
tmux-plugins/tmux-pain-controlImproved consistency for pane management bindings
tmux-plugins/tmux-sessionistExtended session management commands
tmux-plugins/tmux-openOpen URLs and file paths from copy mode
tmux-plugins/tmux-fppQuick file path opening with Facebook PathPicker
catppuccin/tmuxCatppuccin theme
dracula/tmuxDracula theme
wfxr/tmux-fzf-urlURL selection and opening with fzf

10. Advanced Features

10.1 send-keys: Sending Commands to Panes

send-keys is a powerful feature that programmatically sends key input to specific panes.

# Send command to current pane
tmux send-keys "ls -la" Enter

# Send to a specific session, window, and pane
tmux send-keys -t dev:1.0 "npm start" Enter

# Send Ctrl-c (interrupt running process)
tmux send-keys -t dev:1.0 C-c

# Send multiple keys in sequence
tmux send-keys -t dev:1.0 "cd ~/project" Enter "git status" Enter

Target specification syntax:

session:window.pane
dev:1.0         # dev session, window 1, pane 0
:2.1            # current session, window 2, pane 1
monitoring:     # monitoring session, current window

10.2 Tmux Scripting

All Tmux commands can be used in shell scripts to set up complex development environments at once.

#!/bin/bash
# dev-env.sh - Development environment auto-setup script

SESSION="dev"
PROJECT_DIR="$HOME/workspace/my-project"

# Kill existing session if it exists
tmux kill-session -t $SESSION 2>/dev/null

# Create new session (detached mode, first window name: editor)
tmux new-session -d -s $SESSION -n editor -c $PROJECT_DIR

# Run Neovim in editor window
tmux send-keys -t $SESSION:editor "nvim ." Enter

# Create server window
tmux new-window -t $SESSION -n server -c $PROJECT_DIR
tmux send-keys -t $SESSION:server "npm run dev" Enter

# Create logs window (horizontal split)
tmux new-window -t $SESSION -n logs -c $PROJECT_DIR
tmux send-keys -t $SESSION:logs "tail -f logs/app.log" Enter
tmux split-window -v -t $SESSION:logs -c $PROJECT_DIR
tmux send-keys -t $SESSION:logs.1 "tail -f logs/error.log" Enter

# Create test window
tmux new-window -t $SESSION -n test -c $PROJECT_DIR
tmux send-keys -t $SESSION:test "npm test -- --watch" Enter

# Create git window
tmux new-window -t $SESSION -n git -c $PROJECT_DIR
tmux send-keys -t $SESSION:git "git status" Enter

# Move to first window
tmux select-window -t $SESSION:editor

# Attach to session
tmux attach -t $SESSION

10.3 tmuxinator: YAML-Based Session Automation

tmuxinator is a tool that defines Tmux session layouts in YAML files and creates them all at once.

Installation:

# Install via Ruby gem
gem install tmuxinator

# macOS
brew install tmuxinator

Usage:

# Start project
tmuxinator start my-project
# Shorthand
mux my-project

# Stop project
tmuxinator stop my-project

10.4 display-popup (Tmux 3.2+)

Popup windows allow you to perform temporary tasks in a floating window.

# Default popup (auto-closes on exit)
tmux display-popup

# Specify size and position
tmux display-popup -w 80% -h 60% -x C -y C

# Command execution popup
tmux display-popup -E "htop"
tmux display-popup -E -w 90% -h 90% "lazygit"

# Register popup as key binding
bind g display-popup -E -w 80% -h 80% "lazygit"
bind f display-popup -E -w 60% -h 60% "fzf --preview 'cat {}' | xargs nvim"

11. Practical Use Scenarios

11.1 Session Persistence During SSH Remote Work

This is Tmux's most essential use case. Sessions persist on the server even if the SSH connection drops.

# 1. Connect to remote server
ssh user@remote-server

# 2. Start Tmux session
tmux new -s work

# 3. Perform work (build, deploy, monitoring, etc.)
make build && make deploy

# 4. SSH connection drops or intentional detach
# <prefix> d or network disconnect

# 5. Reconnect and resume session
ssh user@remote-server
tmux attach -t work
# All work is preserved exactly as you left it!

11.2 Pair Programming

Tmux's client-server architecture enables multiple users to connect to the same session and work on the same screen in real time.

Method 1: Shared user account

# Developer A: Create session
tmux new -s pair

# Developer B: SSH to same server and attach to session
tmux attach -t pair

# Both developers share the same screen in real-time

Method 3: tmate (Tmux-based remote sharing)

# Install tmate
brew install tmate    # macOS
sudo apt install tmate  # Ubuntu

# Start tmate session
tmate

# Connection URL is displayed
# SSH: ssh xxxxx@lon1.tmate.io
# Web: https://tmate.io/t/xxxxx

11.3 Synchronize Panes Mode

Useful when you need to run the same command on multiple servers simultaneously.

# Enable/disable synchronize mode
<prefix> :setw synchronize-panes on
<prefix> :setw synchronize-panes off

12. Tmux vs Screen vs Zellij Comparison

FeatureTmuxGNU ScreenZellij
Release200719872021
LanguageCCRust
ArchitectureClient-serverSingle processClient-server (WebAssembly plugins)
Vertical SplitBuilt-inPatch needed (4.0+ built-in)Built-in
Mouse SupportConfiguration neededLimitedEnabled by default
ScriptingPowerfulLimitedWASM plugins
Status BarHighly customizableLimitedBuilt-in, tab-bar style
Plugin EcosystemTPM (active)Almost noneWASM plugins (growing)
Learning CurveMediumLowLow (intuitive UI)
Server DeploymentPre-installed on mostPre-installed on mostRequires separate installation

Conclusion:

  • Tmux: The most versatile and powerful, the de facto standard in server environments. Productivity maximizes as you gain proficiency.
  • Screen: Only recommended when already installed on legacy servers. No reason to choose it for new projects.
  • Zellij: A modern Rust-based alternative with intuitive UI and built-in layouts. However, adoption in server environments is still limited.

13. Cheat Sheet: Top 40 Most-Used Commands

13.1 Session Commands

#Command / Key BindingDescription
1tmux new -s nameCreate new session with name
2tmux lsList sessions
3tmux a -t nameAttach to specific session
4tmux new -A -s nameAttach if exists, create if not
5<prefix> dDetach from current session
6<prefix> $Rename current session
7<prefix> sSelect and switch from session list
8tmux kill-session -t nameKill specific session
9tmux kill-serverKill entire Tmux server
10<prefix> ( / <prefix> )Switch to previous/next session

13.2 Window Commands

#Command / Key BindingDescription
11<prefix> cCreate new window
12<prefix> ,Rename current window
13<prefix> n / <prefix> pMove to next/previous window
14<prefix> 0-9Jump directly to window number
15<prefix> wInteractive window selection
16<prefix> lToggle to last used window
17<prefix> &Close current window
18<prefix> fSearch by window name
19tmux move-window -rRenumber windows
20tmux swap-window -t NSwap current window with window N

13.3 Pane Commands

#Command / Key BindingDescription
21<prefix> %Vertical split (left-right)
22<prefix> "Horizontal split (top-bottom)
23<prefix> Arrow keysNavigate panes with arrow keys
24<prefix> oCycle to next pane
25<prefix> zToggle pane zoom (full screen)
26<prefix> xClose current pane
27<prefix> !Break current pane into new window
28<prefix> qShow pane numbers
29<prefix> { / <prefix> }Move pane to previous/next position
30<prefix> SpaceCycle through layouts
31<prefix> Ctrl-ArrowResize pane by 1 cell
32<prefix> Alt-ArrowResize pane by 5 cells

13.4 Copy Mode and Other Commands

#Command / Key BindingDescription
33<prefix> [Enter copy mode
34<prefix> ]Paste buffer contents
35<prefix> ?View key binding list
36<prefix> :Open command prompt
37<prefix> tShow current time
38<prefix> ~View message history
39tmux source ~/.tmux.confReload configuration file
40tmux display-popup -E "cmd"Run command in popup window

14. Troubleshooting

14.1 Colors Not Displaying Correctly

# Problem: Vim/Neovim colors are broken inside Tmux

# Solution: Add to .tmux.conf
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",*256col*:Tc"

14.2 ESC Delay in Neovim

# Problem: Neovim's ESC response is slow inside Tmux

# Solution: Add to .tmux.conf
set -sg escape-time 0

14.3 Mouse Scroll Not Working

# Solution: Enable mouse support
set -g mouse on

14.4 Korean/CJK Input Broken

# Solution: Verify UTF-8 settings
# Check terminal locale settings
locale
# Should show LANG=ko_KR.UTF-8 or en_US.UTF-8

# Add to .bashrc or .zshrc
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

15. Conclusion: Tmux Learning Roadmap

Tmux has an initial learning curve, but once it becomes second nature, terminal work productivity improves dramatically. The following roadmap is recommended for gradual learning.

Level 1 (Day 1)
+-- tmux new / attach / detach / ls / kill-session
+-- <prefix> c / n / p (window create/switch)
+-- <prefix> % / " (pane split)

Level 2 (Week 1)
+-- Pane navigation (<prefix> arrow keys)
+-- Pane zoom (<prefix> z)
+-- Copy mode (<prefix> [)
+-- Basic .tmux.conf settings

Level 3 (Week 2)
+-- Custom key bindings
+-- Status bar customization
+-- Clipboard integration
+-- Mouse settings

Level 4 (Month 1)
+-- TPM plugin system
+-- tmux-resurrect / continuum
+-- send-keys scripting
+-- tmuxinator / tmuxp session automation

Level 5 (Continuous improvement)
+-- display-popup usage
+-- Synchronize panes mode
+-- Nested Tmux operation
+-- Pair programming session sharing

Tmux is not just a terminal tool — it is an infrastructure tool that forms the foundation of server management, development workflows, and remote collaboration. By practicing the commands covered in this guide one by one and building your own .tmux.conf, every minute spent at the terminal will become more efficient.