0

I start tmux session with tmuxinator, one of the windows has 7 panes custom layout

in tmuxinator session config I have lane with layout:

layout: 3db3,233x59,0,0[233x9,0,0{77x9,0,0,3,77x9,78,0,5,77x9,156,0,6},233x9,0,10{77x9,0,10,7,77x9,78,10,8,77x9,156,10,9},233x39,0,20,10]

all works great, tmux opens with correct pane sizes

also I have hook in tmux.conf that reacts on window resize:

set-hook -g window-resized 'select-layout -t s01:4 "3db3,233x59,0,0[233x9,0,0{77x9,0,0,3,77x9,78,0,5,77x9,156,0,6},233x9,0,10{77x9,0,10,7,77x9,78,10,8,77x9,156,10,9},233x39,0,20,10]"'

when I decrease window size and increase back to original size - all panes return to it's original sizes - it's good

in the process of window resizing tmux scale all panes proportionally... I want to keep height 9 for upper six panes, only lower pane height must decrease

also in my terminal emulator present full screen mode, in that mode screen size expands from 233x59 to 236x62... when I go full screen mode I want to keep height 9 for upper six panes, only lower pane height must increase

idea is to modify two parts in hook:

"3db3,233x59,0,0..." -> instead 59 put current screen height

"...233x39,0,20,10]" - > instead 39 put current screen height minus 20(9+1+9+1)

look at the first hook(which made for example), command 'display' shows variable $LAYOUT_STR as expected, with numbers

set-hook -g window-resized 'WINDOW_HEIGHT="#{window_height}"; PANE_HIEGHT="#{e|-:$WINDOW_HEIGHT,20}"; LAYOUT_STR="3db3,233x$WINDOW_HEIGHT,0,0[233x9,0,0{77x9,0,0,3,77x9,78,0,5,77x9,156,0,6},233x9,0,10{77x9,0,10,7,77x9,78,10,8,77x9,156,10,9},233x$PANE_HEIGHT,0,20,10]"; display $LAYOUT_STR'

output:

3db3,233x59,0,0[233x9,0,0{77x9,0,0,3,77x9,78,0,5,77x9,156,0,6},233x9,0,10{77x9,0,10,7,77x9,78,10,8,77x9,156,10,9},233x39,0,20,10]

now look at the hook with select-layout and it's output...

set-hook -g window-resized 'WINDOW_HEIGHT="#{window_height}"; PANE_HIEGHT="#{e|-:$WINDOW_HEIGHT,20}"; LAYOUT_STR="3db3,233x$WINDOW_HEIGHT,0,0[233x9,0,0{77x9,0,0,3,77x9,78,0,5,77x9,156,0,6},233x9,0,10{77x9,0,10,7,77x9,78,10,8,77x9,156,10,9},233x$PANE_HEIGHT,0,20,10]"; select-layout -t s01:4 $LAYOUT_STR'

output:

Invalid layout: 3db3,233x#{window_height},0,0[233x9,0,0{77x9,0,0,3,77x9,78,0,5,77x9,156,0,6},233x9,0,10{77x9,0,10,7,77x9,78,10,8,77x9,156,10,9},233x#{e|-:#{window_height},20},0,20,10])

how to fix it?

1 Answer 1

0

I found solution how to properly do variable substitution in command: ... select-layout -t s01:4 $LAYOUT_STR

correct method is to use 'run-shell' command

this works: ... run-shell -b "exec tmux select-layout -t s01:4 $LAYOUT_STR &"

1
  • Excellent :-) Please don't forget to drop back to accept your answer. This way it gets marked resolved, and won't pop up in the future as "Unanswered". You do need to wait for 48 hours before accepting, tho'. Feb 11 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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