Tmux Cheatsheet
Contents
Some usefuls tips for using Tmux.
In the following text, <prefix>
means the prefix key for Tmux. If you haven’t
changed it, it will Ctrl-b
by default.
Change layout
To change the layout of panes in a Tmux windows, press <prefix><space>
. It
will change between different layouts.
We may also use command select-layout
(or selectl
for short) instead.
Possible layouts are: even-horizontal
, even-vertical
, main-horizontal
,
main-vertical
, tiled
.
Ref:
zoom a pane
To temporarily zoom in and zoom out a pane, press <prefix>z
. It will toggle
the zoom state of current pane.
Create a pane that spans window width
I have two vertical pane side by side in a window, and I want to create a new pane above these two panes, which will span the entire window width. Essentially, I want to change from the following layout:
+--------------+--------------+
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
+--------------+--------------+
to the below layout:
+-----------------------------+
| |
+--------------+--------------+
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
+--------------+--------------+
By default, split-window
command only spans the the width of current pane. We
can use the -f
option to make the new pane span the entire window width. The
help for -f
says that:
-f – create new pane spanning full window width or height
To make the new pane created above, we need to use -b
option:
-b – create new pane left of or above target pane
Combining the two options, we can use the following command to create what we want:
# run the command after pressing <prefix>
:split-window -fbv
Similarly, if we have two pane one on the other, we want to create a new pane, and get the following layout:
+-----------------+-----------+
| | |
| | |
| | |
+-----------------+ |
| | |
| | |
| | |
+-----------------+-----------+
we can use the following command:
:split-window -fh
Ref: