To move a pane to a new window in tmux, press Ctrl+b ! while in the pane you want to move. This converts the current pane into a new window. Alternatively, use the command Ctrl+b :break-pane
.
Ctrl+b !
tmux allows you to reorganize your workspace by moving panes between windows or converting them to new windows entirely. This flexibility helps you adapt your terminal environment as your workflow changes.
The basic command to move the current pane to a new window is:
# Using a key binding Ctrl+b ! # Using the command prompt Ctrl+b :break-pane
This command "breaks out" the current pane, removing it from its current window and creating a new window containing only that pane. The new window will be created at the end of your window list.
You can also specify where you want the new window to be placed:
# Break pane to a specific window index (e.g., 2) Ctrl+b :break-pane -t :2 # Create a new window at index 3 with the current pane Ctrl+b :break-pane -t :3
Instead of creating a new window, you can also move a pane to an existing window:
# Move current pane to window 2 Ctrl+b :join-pane -t :2 # Move current pane to window named "logs" Ctrl+b :join-pane -t logs # Move pane 2 from current window to window 3 Ctrl+b :join-pane -s 2 -t :3
The parameters for join-pane
are:
-s
: Source pane (the pane you want to move)-t
: Target (the window where you want to move the pane) If you omit -s
, the current pane is used as the source.
When joining a pane to a window, you can specify where the pane should appear:
# Join horizontally (side by side) Ctrl+b :join-pane -h -t :2 # Join vertically (stacked) Ctrl+b :join-pane -v -t :2 # Specify a percentage for the size (e.g., 30%) Ctrl+b :join-pane -h -p 30 -t :3
Create custom keybindings for these operations in your ~/.tmux.conf
:
# Add binding to break pane with prefix+B (uppercase B) bind-key B break-pane # Add binding to send pane to window 1 with prefix+J bind-key J join-pane -t :1 # Bind F2 to move the current pane to window 2 bind-key F2 join-pane -t :2
A common workflow is to temporarily break out a pane to work on it in full-screen mode, then rejoin it to its original window when done:
Ctrl+b #
(note the window number)Ctrl+b !
Ctrl+b :join-pane -t :X
(where X is the original window number)