4

I'm on Mac OS X Lion, and I've installed tmux through brew.

I set up a simple window, with a vertical split, and a horizontal split in the right pane for a total of three windows. I also made the leftmost pane larger with resize-pane -R 30. I want to put the layout into a script so I can quickly redo it, so I exported the layout settings with tmux list-windows, and got the following:

bash [318x64] [layout 5ff,318x64,0,0{189x64,0,0,128x64,190,0[128x32,190,0,128x31,190,33]}]

However, when I take the layout line and run

tmux select-layout "5ff,318x64,0,0{189x64,0,0,128x64,190,0[128x32,190,0,128x31,190,33]}"

I get

can't set layout: 5ff,318x64,0,0{189x64,0,0,128x64,190,0[128x32,190,0,128x31,190,33]}

The documentation mentions you can't do it on a layout with more panes than the original layout specified, but that doens't seem to be the problem.

2
  • The example given in the man page suggests that the quotes are not necessary.
    – chepner
    Commented Oct 18, 2012 at 17:10
  • Without the quotes it produces usage: select-layout [-np] [-t target-window] [layout-name]. So it's not behaving properly without them either.
    – Cthos
    Commented Oct 18, 2012 at 17:28

1 Answer 1

5

It looks like there might be a small bug in the tmux code that parses the layout strings. Try prepending a space or a zero so that there are four characters before the first comma.

tmux select-layout ' 5ff,318x64,0,0{189x64,0,0,128x64,190,0[128x32,190,0,128x31,190,33]}'
tmux select-layout '05ff,318x64,0,0{189x64,0,0,128x64,190,0[128x32,190,0,128x31,190,33]}'

It is easy to overlook, but this extra padding is actually present in the list-windows output. Here is an example with one extra space:

0: zsh* (3 panes) [193x46] [layout  71e,193x46,0,0{144x46,0,0,47,48x46,145,0[48x23,145,0,49,48x22,145,24,51]}] @44 (active)

And another with two extra spaces:

0: zsh* (3 panes) [193x46] [layout   49,193x46,0,0{81x46,0,0,47,111x46,82,0[111x23,82,0,49,111x22,82,24,51]}] @44 (active)

The above examples are from tmux 1.7, so they include an extra number for each pane as compared with your examples.


In general, you need to quote these layout strings to prevent the shell from interpreting

  • the commas inside curly braces as “brace expansions” (e.g. frob{ozz,nitz}) and
  • the square brackets as “pathname expansion” (i.e. like a *.[ch] glob/wildcard).

The quoting also makes it easy to include a space as the required padding.

The unintended globbing is unlikely to be a problem because you probably do not have any files that would match these commas-and-digits strings and most shells are configured (by default) to treat unmatched globs as literal strings (they are passed to the command in an unmodified form). The brace expansion, however, is always a problem (in shells that support it) because the shell will expand the layout string into multiple arguments. select-layout is showing you its usage message because it received too many arguments (after the shell performed brace expansion on the layout string).

1
  • That works like a charm. Also thank you for the added explanation about brace expansion.
    – Cthos
    Commented Oct 19, 2012 at 15:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .