Tmux Usage

tmux is a wonderful tool for terminal paneling and can also be used to detach and background a terminal window, similarly to how one might do with screen. The following guide details how I have used tmux over the years. Please feel free to add your own tips and tricks!

Abbreviations

My tmux is not necessarily the same as your tmux. As such, the following abbreviations are used to make this document configuration-agnostic:

AbbreviationTranslation
PPrefix (e.g. Ctrl + b)
MMeta (e.g. Alt)

Splitting

Conventionally, tmux panes can be split horizontally or vertically.

To split panes vertically, use P %.

To split panes horizontally, use P ".

Pane splitting can be nested to a large degree. If you split too much for your screen to handle, tmux will give you an error like “No space for new pane” and not much else will happen.

Assuming you don’t have your tmux to support mouse click navigation, use P followed by an arrow key corresponding to the pane you want to move.

Don’t hold P in this case, otherwise you will adjust the pane. Speaking of…

Adjustment

If you want to resize a given pane, hold P and then press the corresponding arrow key for the direction you want to resize. You can hold the arrow key on some keyboards, but repeatedly pressing the arrow key is more reliable.

Reorganizing

You can reorganize panes into a variety of layouts. To do so, use any of the following (taken from the tmux manual page):

LayoutCommand
Even HorizontalP M 1
Even VerticalP M 2
Main HorizontalP M 3
Main VerticalP M 4
TiledP M 5

Attachment

To detach from a tmux pane, use P d.

To list detached tmux panes, use tmux list-sessions from outside of a tmux instance, or P s from within a tmux session.

To attach to a detached tmux pane, use tmux attach -t <id>, where <id> is the number shown in the session listing.

Miscellany

A few miscellaneous things.

P z will expand the current pane to take the full screen. Useful if you want to briefly move your terminal to see another window. P t will open a clock. Useful if you… need a clock, I guess?