Your First tmux Session
Let’s get you productive with tmux quickly. This guide covers the essential concepts and commands you’ll use daily.Start tmux
[0]- session name0:bash*- window number and name- Your hostname and time on the right
Understand the prefix key
C-b (Ctrl-b)Ctrl and b together, release both keys, then press the command key. For example, C-b c means: press Ctrl-b, release, then press c.Create a new window
C-b c to create a new window.Notice the status bar now shows:* indicates your current window. The - marks the previous window.Navigate between windows
C-b n- next windowC-b p- previous windowC-b 0- switch to window 0C-b 1- switch to window 1C-b l- toggle between current and last window
Split into panes
C-b %- split vertically (left and right)C-b "- split horizontally (top and bottom)
Navigate between panes
C-b o- cycle to next paneC-b ↑- move to pane aboveC-b ↓- move to pane belowC-b ←- move to pane on leftC-b →- move to pane on rightC-b ;- move to previously active pane
Detach from session
C-b d to detach from the session.You’ll see a message:Reattach to session
Essential Commands Reference
Session Management
Session Management
Window Management
Window Management
Pane Management
Pane Management
Pane Resizing
Pane Resizing
Copy Mode and Scrollback
Copy Mode and Scrollback
Enter copy mode
C-b [ to enter copy mode and scroll through history.You’ll see [0/0] in the top-right corner showing your position in history.Navigate in copy mode
- Arrow keys - move cursor
C-Space- begin selectionM-w- copy selectionC-g- exit copy mode
set -g mode-keys vi in config):h/j/k/l- move cursorSpace- begin selectionEnter- copy selectionq- exit copy mode
Paste
C-b ] to paste the most recently copied text.Other Useful Commands
Other Useful Commands
Practical Workflow Example
Here’s a common development workflow:Create a development session
Set up your layout
- Start in your project directory
- Press
C-b %to split vertically - In the right pane, press
C-b "to split horizontally
Run your development tools
- Left pane: Open your editor (
vim,nano, etc.) - Top-right pane: Run your test watcher
- Bottom-right pane: Tail your application logs
Detach when done
C-b d to detach. Your session keeps running.Return later
Remote Development Workflow
One of tmux’s most powerful features is persistence over SSH:SSH to remote server
Start or attach to tmux
Do your work
Disconnect safely
C-b d to detach, then exit SSH:Reconnect anytime
Basic Configuration
Create~/.tmux.conf to customize tmux:
Common Patterns
Create a session with multiple windows
Create a session with multiple windows
Split window with commands
Split window with commands
Troubleshooting
tmux colors look wrong
tmux colors look wrong
.bashrc, .zshrc):~/.tmux.conf:Can't scroll with mouse wheel
Can't scroll with mouse wheel
~/.tmux.conf:C-b : source-file ~/.tmux.confAccidentally detached, how to reattach?
Accidentally detached, how to reattach?
Want to close everything and start fresh
Want to close everything and start fresh
Next Steps
Key Bindings
C-b ? inside tmux to see all default key bindings, or explore customization options.Configuration
~/.tmux.conf including status bar customization, custom key bindings, and hooks.Command Reference
man tmux) for complete command documentation and options.