Moving tmux Panes to Different Windows¶
Table of Contents¶
NOTE: My personal tmux prefix is
Ctrl-a
. The default prefix isCtrl-b
.
Moving Panes¶
- Identify the Target Pane and Window:
- Get the index of the pane you want to move.
prefix+q
- Identify the target window AND pane you want to attach the pane to.
- Get the index of the pane you want to move.
Moving a Pane into a New Window¶
prefix+!
: This will run thebreak-pane
command on the current pane.
or- Navigate to the pane you want to move.
- With your cursor in the pane, enter command mode with
prefix+:
- Use the
break-pane
command.- This will detach the pane from the current window and put it into a new one.
Moving a Pane to a Different Window¶
- Move the Pane to a Different Window:
- Use the
join-pane
command to move the pane. - Syntax:
join-pane -s src-pane -t dst-window # e.g., join-pane -s 1.1 -t 2.1
src-pane
will bex.x
; like1.1
, for "Window 1, Pane 1".dst-window
will be the same:2.1
, for "Window 2, Pane 1".
- Use the
Moving a Pane Around Within the Same Window¶
- OR, if you want to keep the pane in the same window, but attach it to a different
pane:
bash join-pane -s src-pane -t dst-pane # e.g., join-pane -s 1.1 -t 3
- This will attach pane 1 in window 1 to pane 3 in window 1.
Example¶
Assuming you want to move pane 1 from window 1 to window 2, here’s how you can do it:
- Move the Pane from Window 1 to Window 2:
- Use the following command:
tmux join-pane -s 1.1 -t 2.1
- Here,
1.1
represents the first pane in window 1, and2
represents window 2.
- Use the following command:
- Attach pane 1 in window 1 to pane 3 in window 1:
bash :join-pane -s 1.1 -t 2
Summary (TL;DR)¶
-
Determine the source pane and target window.
-
Attach the pane to another pane in the same window:
- Use the
join-pane
command, e.g.,tmux join-pane -s 1.1 -t 2
.tmux join-pane -s 1.1 -t 2
- Use the
-
Move the pane to another pane in a different window:
- Use the
join-pane
command, e.g.,tmux join-pane -s 1.1 -t 2.1
.Joins the pane from the sourcetmux join-pane -s 1.1 -t 2.1
1.1
(window 1, pane 1) to the target pane2.1
(window 2, pane 1).
- Use the
-
Use
prefix
, then:
to enter command mode and typejoin-pane -s 1.1 -t 2
.Moves the pane from the source[prefix]:join-pane -s 1.1 -t 2
1.1
(window 1, pane 1) to the target window2
(window 2).