
Introduction
tmux (terminal multiplexer) is a powerful terminal tool that allows you to manage multiple sessions, windows, and panes within a single terminal window. Whether you’re doing remote development, server management, or daily terminal operations, tmux can greatly enhance your efficiency.
Installing tmux
brew install tmux
Basic Concepts
- Session: The top-level container in tmux. A session can contain multiple windows.
- Window: Each window is like an independent terminal, capable of running different tasks.
- Pane: A window can be further split into multiple panes for parallel multitasking.
Common Command Quick Reference
| Operation | Command/Shortcut | Description |
|---|---|---|
| Start tmux | tmux |
Create a new session |
| Exit tmux | exit or Ctrl+b d |
Exit current pane/detach session |
| List sessions | tmux ls |
List all sessions |
| Attach to session | tmux attach -t <name> |
Attach to a specific session |
| New named session | tmux new -s <name> |
Create and name a new session |
| Kill session | tmux kill-session -t <name> |
Close a specific session |
Note: The default prefix key in tmux is Ctrl+b. All commands require you to press this prefix key first, release it, and then press the corresponding command key.
Session Management
- Create and name a new session
tmux new -s mysession - Detach from session (keep running in background)
PressCtrl+b, thend. - Resume a session
tmux attach -t mysession - List all sessions
tmux ls - Close a session
tmux kill-session -t mysession
Window Operations
- New window:
Ctrl+b c - Switch window:
Ctrl+b n(next),Ctrl+b p(previous) - Rename window:
Ctrl+b , - Close window:
exitorCtrl+d
Pane Operations
- Split horizontally:
Ctrl+b " - Split vertically:
Ctrl+b % - Switch between panes:
Ctrl+band arrow keys - Close pane:
exitorCtrl+d
Feel free to follow my blog at www.bboy.app
Have Fun
