Arranging Windows & Panes in Tmux

I use tmux as my terminal multiplexer and teamocil to manage tmux window layout's. It works quite nicely but then I wanted to customize my layout a little more fancy than normal...

It turns out that gem update teamocil fixed some of the pain I was experiencing as I attempted to make teamocil behave like the documentation.

The Problem

What I wanted was teamocil to arrange my project window like this:

    +-------------------------+----------------+
    |                         |                |
    |                         |                |
    |                         |        1       |
    |                         |                |
    |                         |                |
    +            0            +----------------+
    |                         |                |
    |                         |                |
    |                         |                |
    |                         |        2       |
    |                         |                |
    |                         |                |
    |                         |                |
    +-------------------------+----------------+

But instead, I just kept getting this:

    +--------------------+---------------------+
    |                                          |
    |                    0                     |
    |                                          |
    +--------------------+---------------------+
    |                                          |
    |                    1                     |
    |                                          |
    +--------------------+---------------------+
    |                                          |
    |                    2                     |
    |                                          |
    +--------------------+---------------------+

My original teamocil config looked like this:

session:
    name: blog-session
    windows:
      - name: blog
        root: "~/Documents/dev/active/markgemmill.com"
        layout: main-vertical
        panes:
            - cmd: "vim"
              width: 75
            - cmd: ["ls -al"]
              width: 25
            - cmd: "wintersmith preview"
              width: 25

Where am I?

Teamocil creates a default session called teamocil-session unless you name a session in the config:

... tmux list-sessions
teamocil-session: 1 window (created Thu May 30 11:31:02 2013) [203x52] (attached)

We need to know which window we want to rearrange, so let's see the list of windows:

... tmux list-windows
1: blog* (3 panes) [203x52] [layout e41f,203x52,0,0[203x26,0,0,1,203x12,0,27,3,203x12,0,40,4]] @0 (active)

tmux refers to that window as teamocil-session:1.

In order to rearrange the window, we'll need to run this command:

... tmux select-layout -t teamocil-session:1 main-vertical

Specifying Precise Window Layouts

We can get the current window layout spec like this:

... tmux list-windows
1: blog* (3 panes) [203x52] [layout 809b,203x52,0,0{13052,0,0,11,72x52,131,0[72x25,131,0,12,72x26,131,26,13]}] @4 (active)

The teamocil documentation has the following example to extract the right info to include in it's config:

...tmux list-windows -F "#{window_active} #{window_layout}" | grep "^1" | cut -d " " -f 2
809b,203x52,0,0{130x52,0,0,11,72x52,131,0[72x25,131,0,12,72x26,131,26,13]}

Paste that text into my config:

session:
    name: blog-session
    windows:
      - name: blog
        root: "~/Documents/dev/active/markgemmill.com"
        layout: 809b,203x52,0,0{130x52,0,0,11,72x52,131,0[72x25,131,0,12,72x26,131,26,13]}
        panes:
            - cmd: "vim"
            - cmd: ["ls -al"]
            - cmd: "wintersmith preview"

...and now I get what I want.

Resources

Tags: tmuxtoolsterminal

comments powered by Disqus