Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tmux: Switch the split style of two adjacent panes

Tags:

tmux

I realize that reshaping pane layout in general is not trivial to describe, but I'm interested in at least being able to swap the layout of two adjacent panes.

Suppose I've got these panes laid out like this

 _____________ |    |        | |    |   2    | |    |________| | 0  |        | |    |        | |    |        | |    |   3    | |____|        | | 1  |        | |____|________| 

And I now discover that I want even more vertical space with pane 3. It's clearly not trivial to consider how I could rearrange it with pane 0 or 1 but it would be really nice if I could tell 3 and 2 to flip splitting axis:

 _____________ |    |     |  | |    |     |  | |    |     |  | | 0  |     |  | |    |  3  |2 | |    |     |  | |    |     |  | |____|     |  | | 1  |     |  | |____|_____|__| 

(note here tmux will most likely reorder it so the old 3 becomes the new pane #2)

Currently when I try to run join-pane -h to reorganize it it tells me "cannot join pane to its own window". Yeah, well, I'm just trying to shuffle it without disrupting the entire layout.

I guess a workaround is to break it out to its own named window and then immediately join it back, though it looks like it won't be able to determine the orientation to switch to (horizontal vs vertical).

Note this is different from the operation of swapping the locations of two panes, for which there exists a command ready to use. I'm looking to swap the splitting axis.

like image 696
Steven Lu Avatar asked Mar 15 '13 18:03

Steven Lu


People also ask

How do you swap two panes in tmux?

Tmux uses the keybinding 'Prefix' followed by 'Ctrl+o' to cycle around the panes. When you use this key-binding for the first time, it moves the pane in one position clockwise.

How do I change the pane layout in tmux?

To change the layout of panes in a Tmux windows, press <prefix><space> . It will change between different layouts. We may also use command select-layout (or selectl for short) instead. Possible layouts are: even-horizontal , even-vertical , main-horizontal , main-vertical , tiled .

How do you change panes?

If you hold the Alt key, you can use your arrow keys to move your focus between panes.

How do I close the pane in tmux?

To close a pane, first ensure that you're positioned in it. Then type "exit" or Ctrl-d. Note that there is no need for Ctrl-b in this step. Once you type "exit" or Ctrl-d in the last remaining pane, tmux will close.


1 Answers

Prefix + Space is bound to next layout

like image 197
Brandon Avatar answered Sep 28 '22 16:09

Brandon