# Start new session
tmux
tmux new
# Start new named session
tmux new -s mysession
# List sessions
tmux ls
tmux list-sessions
# Attach to last session
tmux attach
tmux a
# Attach to named session
tmux attach -t mysession
tmux a -t mysession
# Kill session
tmux kill-session -t mysession
# Kill all sessions
tmux kill-server
# Detach from session (inside tmux)
# Prefix + d
Ctrl+b d
# Rename current session
# Prefix + $
Ctrl+b $
# Create new window
# Prefix + c
Ctrl+b c
# Rename current window
# Prefix + ,
Ctrl+b ,
# Close current window
# Prefix + &
Ctrl+b &
# Navigate windows
Ctrl+b n # Next window
Ctrl+b p # Previous window
Ctrl+b 0-9 # Go to window number
# List windows
# Prefix + w
Ctrl+b w
# Find window
# Prefix + f
Ctrl+b f
# Move window
tmux move-window -t 3 # Move to position 3
tmux swap-window -t -1 # Move window left
tmux swap-window -t +1 # Move window right
# Split pane horizontally (top/bottom)
# Prefix + "
Ctrl+b "
# Split pane vertically (left/right)
# Prefix + %
Ctrl+b %
# Navigate panes
Ctrl+b ←↑↓→ # Arrow keys
Ctrl+b o # Next pane
Ctrl+b ; # Last active pane
Ctrl+b q # Show pane numbers
Ctrl+b q 0-9 # Go to pane number
# Resize panes
Ctrl+b Ctrl+←↑↓→ # Resize in direction
Ctrl+b Alt+←↑↓→ # Resize in larger steps
# Close current pane
# Prefix + x
Ctrl+b x
# Toggle pane zoom (fullscreen)
# Prefix + z
Ctrl+b z
# Convert pane to window
# Prefix + !
Ctrl+b !
# Rotate panes
Ctrl+b Ctrl+o # Rotate forward
Ctrl+b Alt+o # Rotate backward
# Toggle pane layouts
# Prefix + Space
Ctrl+b Space
# Enter copy mode
# Prefix + [
Ctrl+b [
# Exit copy mode
q
# Navigation in copy mode (vi keys)
h j k l # Move cursor
w b # Word forward/backward
Ctrl+u Ctrl+d # Page up/down
g G # Start/end of buffer
/ ? # Search forward/backward
n N # Next/previous search match
# Selection (vi mode)
Space # Start selection
Enter # Copy selection
Esc # Clear selection
# Paste buffer
# Prefix + ]
Ctrl+b ]
# List buffers
tmux list-buffers
# Save buffer to file
tmux save-buffer ~/buffer.txt
# Enter command mode
# Prefix + :
Ctrl+b :
# Common commands
:new-session -s name # Create session
:kill-session # Kill current session
:rename-session newname # Rename session
:source-file ~/.tmux.conf # Reload config
:set -g option value # Set option
:setw -g option value # Set window option
:list-keys # List key bindings
:list-commands # List all commands
# Change prefix key to Ctrl+a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Enable mouse support
set -g mouse on
# Start windows and panes at 1
set -g base-index 1
setw -g pane-base-index 1
# Set history limit
set -g history-limit 10000
# Enable vi mode
setw -g mode-keys vi
# Faster escape time
set -sg escape-time 0
# Split panes using | and -
bind | split-window -h
bind - split-window -v
# Reload config
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Pane navigation with vim keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Resize panes with vim keys
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
# Status bar customization
set -g status-style 'bg=#333333 fg=#ffffff'
set -g status-left '[#S] '
set -g status-right '%H:%M %d-%b-%y'
# Window status format
setw -g window-status-current-style 'fg=#ffffff bg=#555555'
# Enable 256 colors
set -g default-terminal "screen-256color"
# Send keys to pane
tmux send-keys -t mysession:0.1 "ls -la" Enter
# Capture pane contents
tmux capture-pane -t 0 -p > output.txt
# Synchronize panes (type in all panes)
# Prefix + : then
:setw synchronize-panes on
:setw synchronize-panes off
# Join pane from another window
tmux join-pane -s 2 -t 1 # Move pane from window 2 to 1
# Break pane to new window
tmux break-pane
# Pipe pane output to file
tmux pipe-pane -o 'cat >> ~/tmux.log'
# Display message
tmux display-message "Hello!"
# Run shell command
tmux run-shell "echo hello"
# Create shared socket
tmux -S /tmp/shared new -s shared
# Set permissions for sharing
chmod 777 /tmp/shared
# Another user attaches
tmux -S /tmp/shared attach -t shared
# Read-only attach
tmux attach -t mysession -r
Ctrl+b ? # List all key bindings
Ctrl+b t # Show clock
Ctrl+b i # Display window info
Ctrl+b ~ # Show messages
Ctrl+b s # List sessions interactively
Ctrl+b ( # Switch to previous session
Ctrl+b ) # Switch to next session
Ctrl+b L # Switch to last session
Ctrl+b D # Choose client to detach