How to join two tmux windows into one, as panes?

from–https://stackoverflow.com/questions/9592969/how-to-join-two-tmux-windows-into-one-as-panes

Asked 
Modified 6 months ago
Viewed 60k times

170

I have two tmux windows, with a single pane in each, and I would like to join these two panes together into a single window as a horizontal split panes. How could I do that?

2 Answers

259

Actually I found the way to do that. Suppose the two windows are number 1 and 2. Use

join-pane -s 2 -t 1 

This will move the 2nd window as a pane to the 1st window. The opposite command is break-pane

  • 48
    Actually join-pane is to move one pane into another, not to move window. join-pane -s 2 -t 1 does not put two windows side by side, but two panes instead. It’s just that the windows happen to have only one pane each. If you have two windows both of which have multiple panes, to put two of panes, say they are pane 0.0 and 1.0, side by side, you can: 1) create a new window 2) move pane 0.0 to pane 2.0 3) move pane 1.0 to pane 2.0 4) kill pane 2.0. Pane 0.0 means the 0th pane of the 0th window.

    – Hong

    Jul 13, 2016 at 13:39

  • 2
    As already said by @Hong the answer solves the issue but the explanation is incorrect. Two windows can be joined and will result into 1 window splitted into 2 panes. And the example of window numbers can also confuse ppl because as the question is made there is no mention of a third window so to put it correctly it should be window number 0 and 1 (tmux starts always with window 0) Maybe the OP could change the question aswell the answer that way that the question will be re-opend and the answer is correctly formulated. But that is my opinion.

    – Charles

    Jan 23, 2018 at 22:21

  • 23
    Note to enter join-pane ... you first enter Ctrl-B then :

    Aug 25, 2020 at 15:03

  • 2
  • 1
    One thing to note that this doesn’t work if you’re already on the mentioned 2nd window.

    – Hritik

    Dec 16, 2020 at 18:48

12

Alternatively, if you don’t want to specify the window names when calling join-pane, you can also mark the pane you want to join into the current window.

Let’s say you want to move a pane from window 2 to window 1. Here’s how to do it:

  1. Switch to window 2.
  2. Mark the desired pane with Prefixm.
  3. Switch to window 1.
  4. Call join-panePrefix :join-pane

上一篇
下一篇