82

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?

7 Answers 7

94

Assuming your prefix key is still the default of CtrlB
To resize down, use: CtrlB:resize-p -D 2
To resize up, use: CtrlB:resize-p -U 2
To resize left, use: CtrlB:resize-p -L 2
To resize right, use: CtrlB:resize-p -R 2

So, this means to first hold Ctrl, then press and release B, then release B, then type a colon (:, which is typically typed by holding Shift and pressing semi-colon ;), then type the word resize and the rest. Those horizontal lines are common hyphens/dashes/minus-signs. At the end of the line, issue a "newline" (pressing Enter or Return depending on what is on the keyboard).

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.

Update: I've certainly appreciated this question. It continues to get upvotes years after being initially posted.

The information I provided above should work in a wide variety of circumstances. For instance, it works when using SSH to control a remote machine that uses OpenBSD which has tmux built-in.

There are some other techniques that some people have found work well for them, and those techniques may use fewer keystrokes. In particular, it seems like tmux has become built-in on Macs and people have had some success with holding down one or more keys. Such techniques are not as likely to work in as wide of a variety of scenarios (such as when using different types of computers/operating systems, and possibly remote terminals), but in some environments an alternate method may be a faster way than what is described by these instructions.

This answer has generated a few comments below that describe some alternates that have worked for other people. If you just want to get the job done with a reliable method, I suggest following the instructions near the top of this answer. If you want to read even further to see about potentially faster methods, make sure to take the time to review comments under this answer because information there has clearly worked well for people too.

7
  • 68
    On my macbook, by default I can use Ctrl+B, then Esc + (arrow key). Nov 21, 2016 at 5:50
  • 8
    @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. Dec 19, 2016 at 6:58
  • 9
    @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, 2017 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, 2017 at 9:25
  • 3
    Ctrl+B and then keep option pressed while hitting an arrow key however many times are needed works for me.
    – Ethan Chen
    Mar 4, 2019 at 22:08
62

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.

4
  • 18
    set -g mouse on #for newer versions Aug 1, 2017 at 10:47
  • 1
    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, 2019 at 12:44
  • How did I not know this?! Amazing thanks, have been using mouse-mode forever, but never realized!!!
    – janniks
    Jan 5, 2020 at 14:37
  • 1
    @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.. Apr 23, 2020 at 1:04
29

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.

2
  • 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, 2019 at 13:26
  • On Mac you have to press the escape key once instead of holding option.
    – McLawrence
    Jul 10, 2020 at 12:50
23

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

3
  • 1
    And now I cannot use h|j|k|l keys Apr 12, 2016 at 6:01
  • 2
    @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, 2016 at 22:55
  • You should swap l with h to have the VI bindings.
    – Hendrik
    Apr 20, 2017 at 18:46
17

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.

1
  • Nice job finding the "works out of the box" example.
    – Cloud
    Feb 5, 2019 at 19:58
0

On Linux, you should be able to use Ctrl+B, then Ctrl+(arrow key), and on my macbook, by default I can use Ctrl+B, then Esc + (arrow key).

If you press the arrow keys in rapid succession, you don't need to re-type Ctrl+B.

0

Ctrl B followed by any of these commands. see description in brackets

: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
  • Adding some explanation will make this an answer. Please use the EDIT button to do this. Mar 24 at 3:57

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.