Skip to content
shellhacks.dev
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
Summarize in AI

One window needs two or three terminals next to each other, and the flags for the direction are easy to mix up.

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 split-window -v -t w
tmux list-panes -t w -F '#{pane_index}: #{pane_width}x#{pane_height} at column #{pane_left}, row #{pane_top}'
tmux kill-server
Text
0: 60x30 at column 0, row 0
1: 59x15 at column 61, row 0
2: 59x14 at column 61, row 16

-h splits the pane horizontally in the sense of putting the new pane beside the old one, which is the % key, and -v stacks a new pane below, which is the " key. That is the reverse of what the word suggests. The listing shows pane 0 on the left at full height and the other two stacked on the right, with the sizes tmux chose. The flags are in the tmux manual.

A new pane starts in the directory where the session began, so add -c '#{pane_current_path}' to open it where you are. The sizes of a detached session come from -x and -y; an attached one uses the terminal. Use -l 30% to give the new pane a size. The output is from tmux 3.3a.

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

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
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.