๐ง How tmux Works
tmux is a terminal multiplexer โ it lets you:
- Start a terminal session that stays alive even if you disconnect (like over SSH)
- Split your terminal into multiple panes and windows
- Switch between tasks or commands without opening new terminals
- Reattach to sessions later
โ๏ธ Basic Concepts
- Session: A named (or unnamed) workspace. Think of it like a virtual terminal container.
- Window: Like a tab in a terminal, inside a session.
- Pane: A split view within a window (horizontal/vertical).
๐ Using tmux with Explicit Session Names
โ Start a session with a name
tmux new-session -s timothason
This creates a new tmux session named mysession and attaches you to it.
๐ Attach to a named session
tmux attach-session -t timothason
# or tmux a -t timothason
๐ List all sessions
tmux ls
๐งฏ Kill a session
tmux kill-session -t mysession
โจ๏ธ Inside tmux: Common Controls
All shortcuts use the prefix key, which is Ctrl+b by default
| Action | Key sequence |
| ------------------ | ------------------------ |
| New window | `Ctrl+b`, then `c` |
| Next window | `Ctrl+b`, then `n` |
| Split vertically | `Ctrl+b`, then `"` |
| Split horizontally | `Ctrl+b`, then `%` |
| Move between panes | `Ctrl+b`, then arrow key |
| Detach | `Ctrl+b`, then `d` |
You can detach from a session and leave it running, then reattach later.
โ Tips
- Use one session per project or task (e.g.
tmux new -s rails). - You can script tmux to auto-start with custom panes/windows.
- Tmux works great with remote servers to avoid losing work if disconnected.