Linux – tmux split into 4 panes

linuxtmuxUbuntu

I am using tmux 2.1.
I have googled this and it seems I can split a window into multiple panes by using the following command:

tmux new-session \; split-window \; split-window -h \; split-window -v

(not sure why the \; is needed but it only works with it)

My issue is the the layout I want is the following:

enter image description here

The only way I can achieve this is by creating 3 windows horizontaly and then going back to the middle window and then splitting that window and I can only do this manually.

Is there anyway to do this via a command?
Thanks!

Best Answer

Briefly, this sequence is what you want:

tmux new-window \; split-window -p 66 \; split-window -d \; split-window -h

The flow is:

  1. tmux new-window: create a window (ok, you wanted a new-session, that does create a window upon startup)
  2. split-window -p 66: allocate bottom two thirds of the vertical space to a secondary pane and focus it
  3. split-window -d: split bottom pane in half, vertically, without focusing the new pane (i.e. focus stays on second – now center – pane)
  4. split-window -h: split center pane in half, horizontally

As for why the \; is needed, check tmux man page:

Multiple commands may be specified together as part of a command sequence. Each command should be separated by spaces and a semicolon; commands are executed sequentially from left to right and lines ending with a backslash continue on to the next line, except when escaped by another backslash. A literal semicolon may be included by escaping it with a backslash (for example, when specifying a command sequence to bind-key).

Related Question