Timothy D Beach
โ† Writing

August 1, 2025 ยท Tmux

How tmux Works

๐Ÿง  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.