Tmux
Tmux is a terminal multiplexer that allows you to manage multiple terminal sessions, windows, and panes within a single screen. Essential commands for session, window, and pane management.
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
Start tmux without session name
Launches tmux and creates a new default session (session 0).
# Start a tmux sessiontmux
# Start tmux with UTF8 supporttmux -u
# Start with specific sockettmux -S ~/.tmux.sockettmux[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.
# 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"tmux new -s development[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
Understanding session, window, and pane hierarchy
Tmux organizes screen space into sessions containing windows, which contain panes.
Session (development)├── Window 0 (editor)│ ├── Pane 0 (active)│ └── Pane 1├── Window 1 (terminal)│ └── Pane 0└── Window 2 (build) ├── Pane 0 ├── Pane 1 └── Pane 2tmux list-sessions && tmux list-windowsdevelopment: 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.
# List all sessionstmux ls
# Get detailed session infotmux info
# Show versiontmux -Vtmux lsdevelopment: 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
Access help and keybindings
Access comprehensive help system and keybinding references within tmux.
# Display keybindings help (in tmux)C-b ?
# Enter command modeC-b :
# List keybindings from shelltmux list-keys
# List all commandstmux list-commandstmux list-keys | head -20bind-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
- [object Object]
Run commands and display help
Display tmux configuration and useful information overlays.
# 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 keytmux show-options -gaggressive-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
Create and attach to new session
Creates a new named session and attaches immediately unless using -d flag.
# 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/myapptmux new -s devwork[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.
# 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 -rtmux attach -t development[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
Switch between sessions
Quickly switch between different sessions from command line or interactively.
# 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-sessiontmux switch -t work[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.
# 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 '!^'tmux lsdevelopment: 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
Detach from session
Safely detach from session, keeping it running in background.
# 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-servertmux detach-client -t development[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.
# List all clients connected to sessiontmux list-clients
# Details about specific sessiontmux display-message -t session -p
# Show session activitytmux list-clients -t sessiontmux list-clients/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
Create new window
Creates new window in current or specified session and switches to it.
# 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 nametmux new-window -t development -n editor[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.
# 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 wtmux select-window -t development:1[switched to window 1]- C-b n and p are essential for workflow
- 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
Rename and reorder windows
Rename windows for better organization and flexibility.
# 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:1tmux rename-window -t development:0 editor[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.
# 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:0tmux list-windows -t development0: 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
Use window list and selection menu
Interactively select windows or monitor them for activity.
# 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 30tmux choose-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
Split panes vertically and horizontally
Create side-by-side (vertical) or stacked (horizontal) pane layouts.
# 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 10tmux split-window -h[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.
# 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 25tmux select-layout even-horizontal[layout changed to even-horizontal]- C-b Space cycles through available layouts
- Layouts auto-arrange panes
- Great for consistent setups
Close and Manage Panes
Remove, move, and organize panes
Close and remove panes
Remove panes or reorganize them across windows.
# 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:1tmux kill-pane -t development:0.1[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.
# 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}"tmux swap-pane -t development:0.0 -s development:0.1[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
Enter scroll mode and navigate
Enter scroll mode to view terminal history and select text.
# 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 modetmux send-keys -t session 'C-b' '['[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.
# 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 offtmux set -g mouse onmouse 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
Copy text in scroll mode
Select text in scroll mode and copy for pasting elsewhere.
# 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 ]echo 'Copy mode workflow'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.
# 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-idtmux list-buffers0: 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
Search within scroll buffer
Find specific text within terminal output history.
# 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 completelyecho 'Search mode: C-b [ then C-s for forward search'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.
# 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 50000tmux capture-pane -t development:0 -p | head -20[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
Essential keybindings and command mode usage
Essential Keybindings Reference
Most frequently used keybindings for daily work
Core session and window keybindings
Quick reference for tmux's most productive keybindings.
SESSION/ATTACHC-b d Detach from sessionC-b ( Previous sessionC-b ) Next session
WINDOWSC-b c New windowC-b n Next windowC-b p Previous windowC-b l Last active windowC-b w List windowsC-b , Rename windowC-b & Kill window
PANESC-b % Split verticalC-b " Split horizontalC-b h/j/k/l Navigate (vim)C-b HJKL Resize (vim)C-b o Next paneC-b x Kill paneC-b Space Cycle layoutsC-b ! Break pane to windowC-b {/} Move pane left/righttmux list-keys | grep -E 'bind-key.*C-b' | head -20bind-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.
COPY/PASTEC-b [ Enter scroll modeC-b ] Paste bufferSpace Start selectionEnter Copy selectionC-s Search forwardC-r Search backward
DISPLAY/INFOC-b ? List keybindingsC-b : Enter command modeC-b t Display clockC-b q Show pane numbersC-b $ Rename sessiontmux list-keys -T copy-mode | head -15send-keys -X copy-selectionsend-keys -X scroll-upsend-keys -X search-forward- Some bindings only work in copy mode
- [object Object]
- t displays clock overlay (press any key to exit)
Command Mode and Advanced Usage
Enter command mode for powerful operations
Access and use command mode
Command mode allows advanced operations like sending keystrokes to panes.
# 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.conftmux send-keys -t development "pwd" Enter/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.
# 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.shtmux list-commands | wc -l135- 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
Create and structure tmux.conf
Create ~/.tmux.conf to customize tmux behavior globally.
# 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 oncat ~/.tmux.conf | head -10set -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.
# 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 -gtmux source-file ~/.tmux.conf[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
Configure left and right status
Customize status bar to show useful information and improve aesthetics.
# 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]"tmux show-options -g | grep statusstatus onstatus-bg defaultstatus-justify leftstatus-left [#S]status-right #H | %a %d %b %H:%M- [object Object]
Colors and Styling
Apply colors and text attributes to UI elements
Apply colors and attributes
Apply color schemes to tmux UI components and text.
# 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"tmux show-options -g status-bgstatus-bg black- [object Object]
- [object Object]
- [object Object]
Apply text attributes and combinations
Combine colors with text attributes for professional appearance.
# 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 colour240echo 'Colors: black, red, green, yellow, blue, magenta, cyan, white'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