123

Is it possible to tell tmux to "resize a pane to 5 lines high"?

I know I can do resize-pane -U 3 to move the dividing line, but sometimes when logging in with a different size monitor the size has changed by a lot of lines that I can't judge by eye. I'd like to be able to have one command that will change one window to exactly the right number of lines rather than faffing about with multiple resize-pane commands.

Hamish Downer
  • 16,603
  • 16
  • 90
  • 84

5 Answers5

183

What about Ctrl-B then (pressing Ctrl) + arrow?

If in tmux < 1.8, doing this by Ctrl-B then (Esc + arrow) * n, where n is the number of times you want to resize.

Teun Zengerink
  • 4,277
  • 5
  • 30
  • 32
leandronsp
  • 1,922
  • 1
  • 10
  • 6
  • 5
    That does `resize-pane -U 1` (or -D ...) which is what I mention in the question. So I know I can do this, and it does work, but I wanted a single command I could map and then reset the size easily. – Hamish Downer Apr 24 '13 at 22:09
  • 4
    Esc + arrow keys work for me. Don't like the fact that there are too many keystrokes though. – clwen Oct 20 '14 at 19:03
  • 2
    I didn't like that either, so added "bind-key J resize-pane -D 5" and "bind-key K resize-pane -U 5" and can resize by pressing J and K – Trenton Apr 28 '15 at 16:46
  • Life saver, thank you, I saw searching for this Ctrl+B and keeping Ctrl with arrow to move pane. – Anil Prz Jun 05 '19 at 11:24
148

In tmux 1.8, the size of the panes may be adjusted interactively. Under the default key bindings this may be done by the prefix key (C-b) followed by the meta key combined with arrow keys (M-arrow), where arrow is one of the up/down/left/right arrow keys.

E.g. Ctrl-b followed by Alt-Up will adjust the size upwards.

Note that the Alt key may be held down while the up/down/left/right keys are pressed multiple times to make multiple adjustments.

E.g. Ctrl-b followed by Alt-Up-Up-Left will adjust the size upwards by two movements and left by one movement.

richardr
  • 5,132
  • 3
  • 18
  • 13
106

usage: resize-pane [-DLRUZ] [-x width] [-y height] [-t target-pane] [adjustment]

ie.

resize-pane -t 1 -y 5

dcat
  • 1,206
  • 1
  • 10
  • 6
  • 3
    The `-x` and `-y` options for `resize-pane` were introduced in *tmux* 1.8. – Chris Johnsen Apr 23 '13 at 06:10
  • 4
    This doesn't work using tmux 1.9 It resizes but not to the correct value. My conf: `set -g default-terminal "screen"` new splitw -v selectp -t 0 resize-pane -t 0 -y 5 set -g status off Its almost like tmux has a minimum value or something for auto setting the rows during load. – tgwaste Jan 12 '16 at 02:11
  • just ignore the above. i can't believe how difficult it is to to write a simple thing on stack overflow. – tgwaste Jan 12 '16 at 02:20
  • 1
    Found a great summary here: https://michaelsoolee.com/resize-tmux-panes/, which says the same thing, but I find that giving a real example instead of documented example is easier to digest - i.e. `:resize-pane -D 10` (Resizes the current pane down by 10 cells). Change `D` to `L`, `R`, `U` as explained above. – jordancooperman Feb 04 '18 at 16:26
  • Also not working for me in tmux 2.6. The pane will not resize below some minimum value (around 20 lines). – Sasgorilla Jul 31 '18 at 16:48
0

while pressing your bind key dont release your fingers and user the narrwors U D L R to resize your pan. BindKey + R to resize to the right side.

Jasem Elayeb
  • 77
  • 1
  • 2
0

On a Mac, it'd have to be <Prefix> + H/J/K/L on Tmux 1.8+. The arrow keys didn't work for me.

Kaka Ruto
  • 4,581
  • 1
  • 31
  • 39