49

I'd like to resize the panes so I can expand / compress the pane sizes (up / down / left / right etc) ..

Any way to get this done?

62

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.

  • 35
    On my macbook, by default I can use Ctrl+B, then Esc + (arrow key). – James M. Lay Nov 21 '16 at 5:50
  • 2
    @JamesM.Lay Oh ya it works either, but how if I want to add 2 or more size? because esc + (arrow) only work once, after that I have to using Ctrl+B then re-apply esc + (arrow) again. – Adiyat Mubarak Dec 19 '16 at 6:58
  • Honestly, I don't know if there is an officially supported way. – James M. Lay Dec 19 '16 at 12:30
  • 4
    @AdiyatMubarak You won't have to use Ctrl+B again if you press Esc + (arrow) in quick succession. Agreed this is not very comfortable, but it works. – th3an0maly Jun 8 '17 at 10:10
  • 2
    @JamesM.Lay alternatively Ctrl+B and M-(arrow) works for me. Usually alt and Esc both send Meta – oLas Aug 31 '17 at 9:25
37

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.

21

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

  • 1
    And now I cannot use h|j|k|l keys – subhojit777 Apr 12 '16 at 6:01
  • 1
    @subhojit777 .. You should still be able to use the [h|j|k|l] keys. Remember for resizing tmux panes you still have to add the prefix key (Ctrl-b by default .. Ctral-a was my override) before you hit those keys. Also, you always have the option to change the binding to whatever you want .. the point was to let people know about saving it in the tmux.conf file – Prashant Jul 6 '16 at 22:55
  • You should swap l with h to have the VI bindings. – Hendrik Apr 20 '17 at 18:46
6

Assuming your prefix key is Ctrl-B (Cmd-B on Mac):

  1. Press Ctrl-B and release
  2. Press and hold Meta (Option on Mac)
  3. While holding Meta press arrow keys repeatedly to resize current pane

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.

5

I just discovered another way. Apparently tmux has two different kinds of key presses (assuming that your prefix key is still Ctrlb)

  1. Press Ctrlb, lift your fingers then press one of the arrow keys. This switches focus.
  2. Press Ctrlb, don't lift your fingers, and then press one of the arrow keys simultaneously. This resizes panes, and I guess is faster than any of the other methods.

In a similar fashion, Ctrlbo also has different behaviours. The first kind of keypress switches focus, and the second kind of keypress swaps panes.

  • Nice job finding the "works out of the box" example. – DevNull Feb 5 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.