Skip to content
shellhacks.dev
Tooling

Resize a pane

Resize a pane with resize-pane -x 30 for an exact width or -R 10 to move its edge. The keys are prefix then Ctrl and an arrow, one cell at a time.

1 min read
Summarize in AI

A pane is too narrow for the output you want to read, and dragging the border by hand is slow.

Shell
tmux kill-server 2>/dev/null; sleep 1
tmux new-session -d -s w -x 120 -y 30
tmux split-window -h -t w
tmux list-panes -t w -F 'pane #{pane_index}: #{pane_width} columns'
tmux resize-pane -t w:0.0 -R 20
tmux list-panes -t w -F 'after -R 20, pane #{pane_index}: #{pane_width} columns'
tmux resize-pane -t w:0.0 -x 30
tmux list-panes -t w -F 'after -x 30, pane #{pane_index}: #{pane_width} columns'
tmux kill-server
Text
pane 0: 60 columns
pane 1: 59 columns
after -R 20, pane 0: 80 columns
after -R 20, pane 1: 39 columns
after -x 30, pane 0: 30 columns
after -x 30, pane 1: 89 columns

-R, -L, -U and -D move the pane's edge by a number of cells in that direction, and -x and -y set an absolute width or height, as described in the resize-pane entry of the manual. The neighbour gives or takes the space, so the widths always add up to the window less one column for the border. The key bindings are prefix then Ctrl and an arrow for one cell, and Alt and an arrow for five.

Sizes persist until the layout is changed, and select-layout or a window resize will recompute them. A pane cannot shrink below one cell, or grow past what its neighbours can give.

Share

More snippets

Tooling

Swap two panes in a window

Swap two panes in a window with swap-pane -s source -t target. The panes keep their IDs and running programs and trade positions, and prefix then braces do it.

2 min read
Tooling

Split a pane

Split a tmux pane with split-window -h for side by side and -v for stacked. The key bindings are prefix then percent and prefix then a double quote.

1 min read
Tooling

Zoom a pane to full screen

Zoom one pane to fill the window with resize-pane -Z, or prefix then z, and call it again to restore. The window shows a Z flag while zoomed.

1 min read

Get new posts by email

One email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.