Tmux Tips 'n Tricks

Back to SIG Tooling & Set Up Tutorials

Here's a high-level `tmux` primer:

1. Start a new session: `tmux` or `tmux new`

2. List sessions: `tmux ls`

3. Reattach to a detached session: `tmux attach` or `tmux attach $SESSION_ID`

From within `tmux`, the prefix key is `C-b` (Hold `Ctrl` and press `b` at the same time.)

After pressing the prefix key, let go and press another key for the `tmux` command that you want to run. This behavior is the same as `screen`'s (which uses `C-a` as its prefix key).

You can see a list of all `tmux` commands with `C-b ?`.

The most common ones you will use are:

1. Create a new window: `C-b c`

2. Kill the current window: `C-b &` or `exit`

3. Next window: `C-b n`

4. Previous window: `C-b p`

5. Detach from session: `C-b d`

6. Split window vertically: `C-b "`

7. Split window horizontally: `C-b %`

8. Kill the current pane (i.e., the split part of a window): `C-b x`

9. Zoom the current pane: `C-b z` (and press `C-b z` again to exit the zoom state)

10. Switch focus to a different pane: `C-b o` or `C-b` and the arrow keys (UP/DOWN/LEFT/RIGHT)