Basics
By default the key combination Ctrl + B
is called the prefix. It must be pressed and released before press the specific shortcut key! It is important to know that all the keys are not pressed together, we need to first release the pressed prefix, then press the specific shortcut key.
On MacOS, the default prefix is also Ctrl + B
, it is neither Cmd + B
nor alt + B
.
为了避免Ctrl + B
先按到B
,建议先按Ctrl
,按着不放的情况下再按B
。然后两个一起松开,再按第三个键(中间可以间隔很多时间)。
- Session: The largest unit managed by tmux. “attach/detach” to the session. Even if you detach from the session, the session continues to run in the background. Multiple sessions can be opened at the same time, each session can have multiple windows. If no name is given, the session will use numbers as its name.
- Window: This is the same tab that exists in the session. You can have multiple windows in one session. You can create and switch windows within a session and switch the entire screen as you move tabs.
- Pane: This is the screen unit existing in the window. You can have multiple panes in a window. If you divide the entire screen vertically by two, two panes are created.
Session
Start session
1 |
|
Exit session
1 |
|
Detach session
1 |
|
Attach session
1 |
|
Session list
1 |
|
Kill session
1 |
|
Rename a session in tmux
1 |
|
Window
<prefix> +
:
c
create window&
kill the current windoww
list windows, which enables switching between windonwsn
next windowp
previous window
Rename a window in tmux
1 |
|
移动 window 到指定位置,改变 tmux window 的编号(用来填补删掉的空缺的 window 编号)
1 |
|
if <target-index>
is occupied, then we will see index in use
.
if <target-index>
is the same as the current index, then we will see same index
.
Pane
<prefix> +
:
"
split into top/bottom panes%
split into left/right panesx
kill the current pane四个方向键
switch between panes
Scroll mode
Prefix then [
then you can use your normal navigation keys to scroll around (eg. Up Arrow
or PgDn
). Press q
to quit scroll mode.
Progress bar in tmux
The problem arises from reattaching to a tmux with a smaller screen. If you reattach in a smaller window, and the size of the output shrinks and gets messed up. But then, if you resize the window to it’s larger size, the output does not enlarge.
One solution:
- Use tmux sessions in Full Screen, enter Full Screen before attaching to a tmux session