Ideally, I'd like it so that I can resize panes by some margin I'd want by just pressing down on the prefix + arrow keys and watch the panel resize till a point that I'm happy with, and I'd just lift my hand to stop the resizing.
2 Answers
By default these bindings (among others) are active:
bind-key -r -T prefix M-Up resize-pane -U 5
bind-key -r -T prefix M-Down resize-pane -D 5
bind-key -r -T prefix M-Left resize-pane -L 5
bind-key -r -T prefix M-Right resize-pane -R 5
bind-key -r -T prefix C-Up resize-pane -U
bind-key -r -T prefix C-Down resize-pane -D
bind-key -r -T prefix C-Left resize-pane -L
bind-key -r -T prefix C-Right resize-pane -RThis means you can resize a pane by prefixAlt ← or prefixCtrl ↓ etc.
(The default prefix is Ctrl B.)
Thanks to -r you can do prefixCtrl ↓↓↓… without repeating prefix many times, if you strike ↓ fast enough. Holding ↓ instead of striking it repeatedly may or may not work. If it doesn't work then it means tmux does not receive the second (or later) ↓ soon enough. In this case you can:
Reconfigure your keyboard. E.g. in my Kubuntu the initial delay is 600 ms, which is higher than the default threshold of 500 ms used by
tmux, therefore holding ↓ doesn't work by default. Then there will be 25 repeats per second, i.e. with the average interval of 40 ms, which is good enough fortmux. Changing 600 ms to 400 ms in the system-wide keyboard settings allows me to use prefixCtrl ↓ (hold).Reconfigure
tmux. The behavior is governed by therepeat-timeoption:repeat-time time
Allow multiple commands to be entered without pressing the prefix-key again in the specified time milliseconds (the default is500). Whether a key repeats may be set when it is bound using the-rflag tobind-key. Repeat is enabled for the default keys bound to theresize-panecommand.Example command (in a shell inside
tmux):tmux set repeat-time 1000Or in
~/.tmux.conf(permanent setting):set -g repeat-time 1000
Whichever method you choose (one or both), you want repeat-time in tmux to be higher than the delay and the repeat interval in your keyboard settings. Then you will even be able to
prefixCtrl ↓ (hold)↑ (hold)← (hold)→ (hold)…
with just one prefix and without releasing Ctrl, if only you switch between ↓, ↑, ← and → fast enough. If your prefix includes Ctrl then you don't need to release it. I mean with the default prefix of Ctrl B you can do this:
Ctrl B↓ (hold)↑ (hold)← (hold)→ (hold)…
holding Ctrl during the entire sequence.
1To resize tmux panes, you’ll first want to hit your prefix — ctrl + b by default — and then the colon key :. What this does is brings up a prompt at the bottom of your screen.
Now you’ll want to type in resize-pane in the prompt, followed by a hyphen - and either D, U, L, R. Which you can probably guess stands for down, up, left and right, the direction in which you want your pane to be resized. When using the resize-pane command, the resize will be applied to the last pane that had focus.
Here is an example of the entire resize pane command that resizes the pane to the left by a cell — the unit in which tmux resizes:
// This assumes that you've hit ctrl + b and : to get to the command prompt :resize-pane -L Here are some additional tmux pane resizing examples:
:resize-pane -D (Resizes the current pane down)
:resize-pane -U (Resizes the current pane upward)
:resize-pane -L (Resizes the current pane left)
:resize-pane -R (Resizes the current pane right)
:resize-pane -D 10 (Resizes the current pane down by 10 cells)
:resize-pane -U 10 (Resizes the current pane upward by 10 cells)
:resize-pane -L 10 (Resizes the current pane left by 10 cells)
:resize-pane -R 10 (Resizes the current pane right by 10 cells) 1