Question

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.

Was it helpful?

Solution 2

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"

OTHER TIPS

Tmux has gained this functionality now as of v2.1 (see CHANGES):

* 'select-layout' understands '-o' to undo the last layout change.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top