You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Bind keys
tmux bind-key h select-pane -L # bind h to select left pane
tmux bind-key -r j resize-pane -D # bind j to resize down (repeatable)
tmux bind-key -n C-h select-pane -L # bind without prefix# Send keys
tmux send-keys -t mysession:1 'ls -la' Enter
tmux send-keys -t 1.2 C-c # send Ctrl+C to pane 2
Option Commands
Command
Options
Description
set-option
-a, -g, -o, -q, -s, -u, -w
Set session/window option
set-window-option
-a, -g, -o, -q, -u
Set window option
show-options
-A, -g, -H, -q, -s, -v, -w
Show options
show-window-options
-g, -v
Show window options
Option Examples
# Set options
tmux set-option -g prefix C-a # global prefix key
tmux set-option -g mouse on # enable mouse globally
tmux set-window-option -g mode-keys vi # vi keys in copy mode# Show options
tmux show-options -g # show global options
tmux show-options -g prefix # show specific option
Environment Commands
Command
Options
Description
set-environment
-g, -r, -u
Set environment variable
show-environment
-g, -s, -t target
Show environment
Advanced CLI Usage
# Multiple commands in one line
tmux new-session -d -s dev \; split-window -h \; select-pane -t 0
# Conditional execution
tmux has-session -t mysession 2>/dev/null && tmux attach -t mysession || tmux new -s mysession
# Format strings for output
tmux list-sessions -F "Session: #{session_name} (#{session_windows} windows)"
tmux list-panes -F "#{pane_id}: #{pane_current_command} in #{pane_current_path}"# Using tmux in scripts#!/bin/bashif! tmux has-session -t work 2>/dev/null;then
tmux new-session -d -s work -c ~/projects
tmux split-window -h -c ~/projects
tmux new-window -c ~/logs -n logs
fi
tmux attach-session -t work
Common Format Variables
Variable
Description
#{session_name}
Session name
#{session_windows}
Number of windows in session
#{window_name}
Window name
#{window_index}
Window index
#{pane_id}
Pane identifier
#{pane_current_command}
Current command in pane
#{pane_current_path}
Current path in pane
#{client_width}
Client width
#{client_height}
Client height
Session Management
Creating & Attaching Sessions
Command
Description
tmux
Start new session
tmux new -s <name>
Start new session with name
tmux new -s <name> -d
Start new detached session
tmux ls
List all sessions
tmux list-sessions
List all sessions (verbose)
tmux attach
Attach to last session
tmux attach -t <name>
Attach to named session
tmux a -t <name>
Attach to named session (short)
Inside tmux Session
Shortcut
Description
<prefix> + d
Detach from session
<prefix> + D
Choose session to detach
<prefix> + s
List and switch sessions
<prefix> + $
Rename current session
<prefix> + (
Switch to previous session
<prefix> + )
Switch to next session
<prefix> + L
Switch to last used session
Killing Sessions
Command
Description
tmux kill-session -t <name>
Kill named session
tmux kill-session -a
Kill all sessions except current
tmux kill-server
Kill tmux server and all sessions
<prefix> + x
Kill current pane/window
Window Management
Creating & Navigation
Shortcut
Description
<prefix> + c
Create new window
<prefix> + ,
Rename current window
<prefix> + n
Next window
<prefix> + p
Previous window
<prefix> + l
Switch to last used window
<prefix> + w
List windows (interactive)
<prefix> + f
Find window by name
<prefix> + 0-9
Switch to window by number
<prefix> + '
Switch to window by number (prompt)
Window Operations
Shortcut
Description
<prefix> + &
Kill current window
<prefix> + .
Move current window (prompt for number)
<prefix> + <
Move window left
<prefix> + >
Move window right
Window Monitoring
Shortcut
Description
<prefix> + M
Monitor window for activity
<prefix> + m
Monitor window for silence
Pane Management
Creating & Splitting
Shortcut
Description
<prefix> + %
Split pane horizontally (left/right)
<prefix> + "
Split pane vertically (top/bottom)
<prefix> + c
Create new window (single pane)
Navigation
Shortcut
Description
<prefix> + ←↑↓→
Navigate between panes
<prefix> + h/j/k/l
Navigate panes (vim-style, if configured)
<prefix> + o
Switch to next pane
<prefix> + ;
Switch to last used pane
<prefix> + q
Show pane numbers
<prefix> + q + 0-9
Switch to pane by number
Resizing Panes
Shortcut
Description
<prefix> + Ctrl+←↑↓→
Resize pane in direction
<prefix> + Alt+←↑↓→
Resize pane in direction (5 cells)
<prefix> + z
Toggle pane zoom (full screen)
Pane Operations
Shortcut
Description
<prefix> + x
Kill current pane
<prefix> + !
Break pane into new window
<prefix> + {
Move current pane left
<prefix> + }
Move current pane right
<prefix> + Ctrl+o
Rotate panes clockwise
<prefix> + Alt+o
Rotate panes counter-clockwise
Pane Layouts
Shortcut
Description
<prefix> + Space
Cycle through predefined layouts
<prefix> + Alt+1
Even horizontal layout
<prefix> + Alt+2
Even vertical layout
<prefix> + Alt+3
Main horizontal layout
<prefix> + Alt+4
Main vertical layout
<prefix> + Alt+5
Tiled layout
Pane Synchronization
Shortcut
Description
:setw synchronize-panes on
Synchronize input to all panes
:setw synchronize-panes off
Turn off synchronization
<prefix> + :
Enter command mode
Copy Mode & Scrolling
Entering Copy Mode
Shortcut
Description
<prefix> + [
Enter copy mode
<prefix> + PgUp
Enter copy mode and scroll up
Navigation in Copy Mode (vi-mode)
Shortcut
Description
h/j/k/l
Move cursor left/down/up/right
w/b
Move word forward/backward
0/$
Move to start/end of line
g/G
Move to start/end of buffer
Ctrl+b/Ctrl+f
Page up/down
/
Search forward
?
Search backward
n/N
Next/previous search result
Selection & Copying (vi-mode)
Shortcut
Description
Space
Start selection
Enter
Copy selection and exit copy mode
v
Start visual selection
V
Start line-wise selection
y
Copy selection
Escape
Clear selection
q
Exit copy mode
Emacs-mode Copy Commands
Shortcut
Description
Ctrl+Space
Start selection
Ctrl+w
Copy selection
Alt+w
Copy selection (alternative)
Pasting
Shortcut
Description
<prefix> + ]
Paste last copied text
<prefix> + =
Choose buffer to paste from
<prefix> + #
List paste buffers
Status Bar & Monitoring
Status Bar Controls
Shortcut
Description
<prefix> + t
Show time
<prefix> + i
Display window information
Command Mode
Shortcut
Description
<prefix> + :
Enter command mode
:source-file ~/.tmux.conf
Reload configuration
:list-keys
List all key bindings
:list-commands
List all commands
:show-options -g
Show global options
:show-options -w
Show window options
Configuration
Basic .tmux.conf Settings
# Change prefix key to Ctrl+aset -g prefix C-a
unbind C-b
bind C-a send-prefix
# Enable mouse supportset -g mouse on
# Vi mode for copy mode
setw -g mode-keys vi
# Start windows and panes at 1, not 0set -g base-index 1
setw -g pane-base-index 1
# Renumber windows when one is closedset -g renumber-windows on
# Increase scrollback bufferset -g history-limit 10000
# Enable 256 colorsset -g default-terminal "screen-256color"# Status bar customizationset -g status-bg black
set -g status-fg white
set -g status-left '[#S] 'set -g status-right '%Y-%m-%d %H:%M'# Pane border colorsset -g pane-border-style fg=black
set -g pane-active-border-style fg=red
# Window activity monitoring
setw -g monitor-activity on
set -g visual-activity on
Custom Key Bindings
# Vim-style pane navigationbind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Vim-style pane resizingbind -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
# Split panes more intuitivelybind| split-window -h
bind - split-window -v
# Quick pane synchronization togglebind S setw synchronize-panes
# Easy config reloadbind r source-file ~/.tmux.conf \; display-message "Config reloaded!"