Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tmux bind shortcut to create a pane above or to the left?

Tags:

tmux

Whenever I use tmux split-window -h/v, it creates the new split to the right/bottom, respectively. I want a command that creates the new split on the other side (i.e., to the left/top), but I can't find any simple answer for this anywhere... How can I bind this behavior into a shortcut?

What happens by default:

 _______                         _______
|       |                       |   |   |
|   *   | == split-window -h => |   | * |
|       |                       |   |   |
 -------                         -------

What I want a shortcut for:

 _______                         _______
|       |                       |   |   |
|   *   | ==        ?        => | * |   |
|       |                       |   |   |
 -------                         -------
like image 548
Brian Rodriguez Avatar asked May 26 '17 16:05

Brian Rodriguez


People also ask

How do I create a new pane in tmux?

For example, to create a new window the hard way, you can press Ctrl+B followed by : to enter the tmux command line. Type new-window and press Enter to create a new window. This does exactly the same thing as pressing Ctrl+B then C.

How do I move tmux panes?

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 move a pane from one window to another in tmux?

by default. Execute this in the tmux command-line: :join-pane -t <int> , where <int> is the index of the window you want to move it into. You can optionally specify -h or -v to explicitly tell tmux to attach the current pane as a horizontal-split or a vertical-split on the target window, respectively.


Video Answer


1 Answers

As from version 2.0, tmux's split-window and join-window understand -b to create the pane to the left or above the target pane.

Split horizontally and place at the left:

tmux split-window -hb

Split vertically and place at the top:

tmux split-window -vb

Update:

From inside tmux you can use } for swapping the panels once you have split the window:

Example for vertical splitting:

Ctrl + B + %
Ctrl + B + }
like image 164
JuanR Avatar answered Oct 29 '22 00:10

JuanR