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:Essential Commands Reference
Session Management
Session Management
Window Management
Window Management
| Key Binding | Action |
|---|---|
C-b c | Create new window |
C-b , | Rename current window |
C-b & | Kill current window (with confirmation) |
C-b n | Next window |
C-b p | Previous window |
C-b 0-9 | Switch to window by number |
C-b l | Switch to last active window |
C-b w | Interactive window list |
C-b f | Find window by name |
C-b . | Move window to different index |
Pane Management
Pane Management
| Key Binding | Action |
|---|---|
C-b % | Split pane vertically |
C-b " | Split pane horizontally |
C-b x | Kill current pane (with confirmation) |
C-b o | Move to next pane |
C-b ; | Move to previously active pane |
C-b ↑↓←→ | Move to pane in direction |
C-b { | Swap with previous pane |
C-b } | Swap with next pane |
C-b z | Toggle pane zoom (fullscreen) |
C-b ! | Break pane into new window |
C-b q | Show pane numbers |
Pane Resizing
Pane Resizing
| Key Binding | Action |
|---|---|
C-b C-↑ | Resize pane up by 1 cell |
C-b C-↓ | Resize pane down by 1 cell |
C-b C-← | Resize pane left by 1 cell |
C-b C-→ | Resize pane right by 1 cell |
C-b M-↑ | Resize pane up by 5 cells |
C-b M-↓ | Resize pane down by 5 cells |
C-b M-← | Resize pane left by 5 cells |
C-b M-→ | Resize pane right by 5 cells |
C-b M-1 to M-7 | Apply preset layouts |
C-b Space | Cycle through preset layouts |
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
Other Useful Commands
Other Useful Commands
| Key Binding | Action |
|---|---|
C-b ? | List all key bindings |
C-b : | Enter command prompt |
C-b t | Show clock |
C-b i | Display window information |
C-b ~ | Show previous messages |
C-b d | Detach from session |
C-b D | Choose client to detach |
C-b r | Redraw screen |
C-b C-b | Send literal C-b to application |
Practical Workflow Example
Here’s a common development workflow: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
Remote Development Workflow
One of tmux’s most powerful features is persistence over SSH:Disconnect safely
C-b d to detach, then exit SSH: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
Share a session with another user
Share a session with another user
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.