61

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?

73

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.

| improve this answer | |
  • 57
    On my macbook, by default I can use Ctrl+B, then Esc + (arrow key). – James M. Lay Nov 21 '16 at 5:50
  • 6
    @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
  • 6
    @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
  • 3
    @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
  • 2
    Ctrl+B and then keep option pressed while hitting an arrow key however many times are needed works for me. – Yuxuan Chen Mar 4 '19 at 22:08
47

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.

| improve this answer | |
  • 5
    set -g mouse on #for newer versions – Loves Probability Aug 1 '17 at 10:47
  • My life just changed! This works on my Ubuntu instance on WSL (Windows Subsystem for Linux) ... oh, but now I can't paste with the right mouse button anymore. Linux on Window is still awkward. – flickerfly Jul 30 '19 at 12:44
  • How did I not know this?! Amazing thanks, have been using mouse-mode forever, but never realized!!! – janniks Jan 5 at 14:37
  • @flickerfly If you hold shift, while using the mouse it wont send the input to tmux, ie Shift + drag to highlight console, or Shirt + right click for paste, etc.. – Chris Seufert Apr 23 at 1:04
22

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

| improve this answer | |
  • 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
20

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.

| improve this answer | |
  • This is the easiest for me to remember but sometimes it takes too long. Is it possible to change how much each arrow key tap increments the pane size? – connorbode Oct 8 '19 at 13:26
  • On Mac you have to press the escape key once instead of holding option. – McLawrence Jul 10 at 12:50
9

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.

| improve this answer | |
  • Nice job finding the "works out of the box" example. – Cloud Feb 5 '19 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.