Câu trả lời:
Assuming your prefix key is still the default of Ctrl-B
^B :resize-p -D 2
^B :resize-p -U 2
^B :resize-p -L 2
^B :resize-p -R 2
The numbers at the end are optional, defaulting to 1. The -U is also a default, and is unnecessary.
If you ever forget that, ^B ? will show these found to C-Up and C-Down and C-Left and C-Right, at the end of the keys (with the default key bindings).
You could also try pressing Ctrl+B followed by a Ctrl+arrow-keys.
However, note that Ctrl-arrow-keys may be problematic on some terminals. So you can either try to address the terminal limitations, or create new shortcut key bindings, or just not use shortcuts and use the longer commands shown above.
esc + (arrow)
only work once, after that I have to using Ctrl+B
then re-apply esc + (arrow)
again.
Ctrl+B
again if you press Esc + (arrow)
in quick succession. Agreed this is not very comfortable, but it works.
Ctrl+B
and M-(arrow)
works for me. Usually alt
and Esc
both send Meta
Ctrl+B
and then keep option
pressed while hitting an arrow key however many times are needed works for me.
One option for resizing panes is to use the mouse. To do this, add these lines to your .tmux.conf
:
set -g mode-mouse on
set -g mouse-resize-pane on
If you are on a Mac and the above doesn't work, use this instead (source):
set-option -g mouse on
Once this mode is on, simply click and drag on pane dividers to resize them.
set -g mouse on
#for newer versions
I just added the following lines to my tmux.conf file
bind j resize-pane -D 10
bind k resize-pane -U 10
bind l resize-pane -L 10
bind h resize-pane -R 10
and now I can use Ctrl-a (my prefix key) with [h|j|k|l] to resize the panes
l
with h
to have the VI bindings.
Assuming your prefix key is Ctrl-B (Cmd-B on Mac):
It seems however that there is some timeout so if you don't press an arrow key while holding Meta within 1 or 2 seconds Meta-{arrow} will be considered as an input in current prompt.
I just discovered another way. Apparently tmux
has two different kinds of key presses (assuming that your prefix key is still Ctrlb)
In a similar fashion, Ctrlbo also has different behaviours. The first kind of keypress switches focus, and the second kind of keypress swaps panes.
Ctrl+B
, thenEsc + (arrow key)
.