📱 Session Management
tmux or tmux new
Start a new tmux session
tmux new -s mysession
Start a new session with name "mysession"
tmux ls
List all sessions
tmux attach or tmux a
Attach to last session
tmux attach -t mysession
Attach to session named "mysession"
Ctrl+b d
Detach from current session
Ctrl+b s
List and switch between sessions
Ctrl+b $
Rename current session
tmux move-window -s session1 -t session2
Move window from session1 to session2 (merge sessions)
tmux link-window -s session1:# -t session2
Link window to another session (appears in both)
🪟 Window Management
Ctrl+b c
Create a new window
Ctrl+b w
List and switch between windows
Ctrl+b n
Switch to next window
Ctrl+b p
Switch to previous window
Ctrl+b 0-9
Switch to window by number
Ctrl+b &
Kill current window
Ctrl+b ,
Rename current window
Ctrl+b f
Find window by name
tmux select-window -t session:window
Navigate to specific window - CLI command
Ctrl+b '
Prompt for window index number
tmux attach -t session \; select-window -t #
Attach to session and open specific window
🔲 Pane Management
Ctrl+b %
Split pane vertically (side by side)
Ctrl+b "
Split pane horizontally (top and bottom)
Ctrl+b arrow keys
Navigate between panes
Ctrl+b q
Show pane numbers
Ctrl+b o
Switch to next pane
Ctrl+b ;
Toggle between current and previous pane
Ctrl+b x
Kill current pane
Ctrl+b z
Toggle pane zoom (fullscreen)
Ctrl+b !
Break pane into new window
Ctrl+b space
Toggle between pane layouts
tmux split-window
Split horizontally (top/bottom) - CLI command
tmux split-window -h
Split vertically (side by side) - CLI command
tmux select-pane -t #
Navigate to pane by number - CLI command
Ctrl+b q, then 0-9
Display pane numbers, then jump to pane
🛠️ Miscellaneous
Ctrl+b ?
Show all key bindings
Ctrl+b :
Enter command mode
Ctrl+b [
Enter copy mode (scroll/search)
Ctrl+b ]
Paste from tmux buffer
Ctrl+b t
Show clock
tmux kill-server
Kill all tmux sessions and server
tmux split-window -h 'command'
Split and run specific command in new pane
tmux select-pane -U/-D/-L/-R
Navigate panes by direction (Up/Down/Left/Right)
tmux select-pane -l
Navigate to last active pane
🌐 Remote SSH Session with Multiple Panes
Recommendation: Use PANES (not windows)
Why Panes? For running different commands simultaneously on the same remote machine, panes are better because:
- ✅ Single SSH connection - More efficient, less overhead
- ✅ Visual context - See all outputs at once
- ✅ Easier switching - Quick navigation with arrow keys
- ✅ Shared environment - Same working directory and environment variables
🚀 One-liner to create remote session with 2 panes:
ssh user@remote-host -t 'tmux new-session -d -s "remote-work" \; split-window -h \; attach'
📝 Step-by-step breakdown:
# Connect to remote host and create tmux session
ssh user@remote-host -t 'tmux new-session -d -s "remote-work"'
# Split the window horizontally (2 panes side by side)
# Then attach to the session
ssh user@remote-host -t 'tmux attach -t "remote-work" \; split-window -h'
⚡ Alternative approach (more control):
# SSH into remote machine first
ssh user@remote-host
# Then create session with 2 panes
tmux new-session -d -s "work-session"
tmux split-window -h -t "work-session"
tmux attach -t "work-session"
🎯 Quick navigation once inside:
Ctrl+b % # Split vertically (if you need more panes)
Ctrl+b " # Split horizontally
Ctrl+b arrow-keys # Navigate between panes
Ctrl+b z # Toggle fullscreen for current pane