5

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!

14

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).

  • Thanks for this. I only got your command to work if I used tmux new-session. tmux new-window did nothing. Thanks also for taking the time to explain the \; thing :) – AntonioCS Dec 13 '16 at 10:57
  • A quick note: It seems your command will work on already existing tmux session. (sorry still new to tmux) I sometimes use a few terminals with different tmux sessions as I am working on different projects and I need different displays for them. – AntonioCS Dec 13 '16 at 11:02
  • How do you add a 5th 20% width of the screen pane to the left of the whole area? – rubo77 Aug 26 '18 at 13:03
  • @rubo77: tmux split-window -f -h -p 20 -t :.1 -b – altblue Aug 27 '18 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.