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?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityAssuming 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.
Ctrl+B
, then Esc + (arrow key)
.
Nov 21, 2016 at 5:50
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
Ctrl+B
again if you press Esc + (arrow)
in quick succession. Agreed this is not very comfortable, but it works.
Jun 8, 2017 at 10:10
Ctrl+B
and M-(arrow)
works for me. Usually alt
and Esc
both send Meta
Ctrl+B
and then keep option
pressed while hitting an arrow key however many times are needed works for me.
Mar 4, 2019 at 22:08
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.
Assuming your prefix key is Ctrl-B (Cmd-B on Mac):
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.
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
I just discovered another way. Apparently tmux
has two different kinds of key presses (assuming that your prefix key is still Ctrlb)
In a similar fashion, Ctrlbo also has different behaviours. The first kind of keypress switches focus, and the second kind of keypress swaps panes.
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.
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)