How to Resize Tmux Panes
tmux is one of the best terminal multiplexers out there. I’ve been using tmux for 5+ years and I can’t think any development workflow without it.
Being able to have multiple sessions/windows/panes in a single terminal instance has definitely great benefits. It also has persistent sessions and sharing capabilities as well.
By default when creating panes — whether horizontal or vertical, tmux splits the window into 50% panes. But sometimes I just need a small pane to look at.
Info
You can create horizontal or vertical splits by running in tmux command mode:
# horizontally
:split-window -h
# vertically
:split-window -v
In order to resize tmux panes, you first hit your tmux prefix
(ctrl + b
is the default one. Mine is ctrl + a
.), and then the colon key :
.
This brings up a tmux command mode prompt at the bottom of your screen.
For resizing panes general args syntax is like below:
:resize-pane -$DIRECTION $cell-size
Below is an example of the entire resize pane command that resizes the active pane to the down by 30 cells. Cell is the unit in which tmux resizes:
:resize-pane -D 30
Here are examples for all directions:
:resize-pane -L 20 # Resizes the current pane Left by 20 cells
:resize-pane -R 20 # Resizes the current pane Right by 20 cells
:resize-pane -D 20 # Resizes the current pane Down by 20 cells
:resize-pane -U 20 # Resizes the current pane Upward by 20 cells
Info
You can also run this tmux commands from your shell (bash, zsh, fish) by running:
$ tmux resize-pane -D 10
All done!