Tmux: how to restore layout after changing it with select-layout or next-layout?
terminal, tmux
Solution
You can capture the current window layout using `display-message`
layout=$( tmux display-message -p "#{window_layout}" )
Note that this works in tmux version 1.7 or later. If you are using an older version, you could try extracting the layout string from the `list-windows` command. One way to do it is as follows:
layout=$( tmux list-windows | sed -e 's/^.*\[layout \(\S*\)].*$/\1/' )
and now you can use that variable, to restore your layout at a later time, with `select-layout`:
tmux select-layout "$layout"
Problem
After starting a new tmux session I usually open multiple panes in the default window, and then resize them manually using the resize-pane commands (through shortcuts of course). After doing some work, I arrive at a point, or have a certain kind of output, that I want to quickly view side-by-side vertically or horizontally. So I use the select-layout or the next-layout commands. However once I'm done with these views, I want to go back to the layout that I set up originally. Is there any command/procedure that can let me do that? Not only do I seem to not be able to restore to my original layout, I can't seem to do that with manual resizing either.