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?

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
RNA
  • 146,987
  • 15
  • 52
  • 70
  • 4
    here is a good answer to the question. http://superuser.com/questions/266567/tmux-how-can-i-link-a-window-as-split-window – ekangas Aug 07 '15 at 20:01

2 Answers2

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

Jay
  • 18,959
  • 11
  • 53
  • 72
RNA
  • 146,987
  • 15
  • 52
  • 70
  • 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 '16 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 '18 at 22:21
  • is there a keyboard shortcut for this that I can map to? – Ishan Khare Oct 17 '19 at 11:40
  • 23
    Note to enter `join-pane ...` you first enter Ctrl-B then : – Noel Evans Aug 25 '20 at 15:03
  • 2
    @IshanKhare this is good shortcut: https://unix.stackexchange.com/a/14301/337677 – Noel Evans Aug 25 '20 at 15:04
  • 1
    One thing to note that this doesn't work if you're already on the mentioned 2nd window. – Hritik Dec 16 '20 at 18:48
  • @RNA Great many thanks! However this seems not to work if there are already several panes in the windows to merge. Is there a solution for this? – ecjb Aug 23 '22 at 07:19
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-pane: Prefix :join-pane
Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79