Skip to content
shellhacks.dev
Tooling

Break a pane into a window

Move a pane into a new window with break-pane, or prefix then an exclamation mark, and bring it back with join-pane. The process in it keeps running.

2 min read
Summarize in AI

A pane that you want to keep running is taking up room, and it should move to a window of its own.

Shell
tmux kill-server 2>/dev/null; sleep 1
tmux new-session -d -s w -x 120 -y 30
tmux split-window -t w
tmux list-windows -t w -F 'window #{window_index}: #{window_name}, #{window_panes} pane(s)'
echo ---
tmux break-pane -d -s w:0.1 -n logs
tmux list-windows -t w -F 'window #{window_index}: #{window_name}, #{window_panes} pane(s)'
echo ---
tmux join-pane -s w:logs -t w:0
tmux list-windows -t w -F 'window #{window_index}: #{window_name}, #{window_panes} pane(s)'
tmux kill-server
Text
window 0: bash, 2 pane(s)
---
window 0: bash, 1 pane(s)
window 1: logs, 1 pane(s)
---
window 0: bash, 2 pane(s)

break-pane takes a pane out of its window and gives it a window of its own, and -n names that window. The shell or program inside is not touched, so a build or a tail keeps going. join-pane does the reverse, moving a pane into another window as a split, which the last listing shows with the second window gone. Both are in the tmux manual. Without -d the new window is selected at once.

A window with a single pane cannot be broken further, and the command fails. Window numbers can shift if renumber-windows is on. Tmux has no undo, so remember the name you gave the window before joining it back. The output is from tmux 3.3a.

Share

More snippets

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

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

Get new posts by email

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

Unsubscribe in one click. No spam, ever.