Tmux: Maximizing/Zooming A Pane To A New Window

tmux is a terminal multiplexer (similar to GNU Screen) that runs on UNIX-like operating systems: Mac, Linux, FreeBSD, etc.

tmux 1.8 got released on March, 26th 2013 with the ability to zoom panes temporarily to the full size of the current window. The manual for the resize-pane command now states:

With -Z, the active pane is toggled between zoomed (occupying the whole of the window) and unzoomed (its normal position in the layout).

However, I still prefer my tmux 1.6 and 1.7 compatible hack that maximizes a pane to a new window.

At the time I started looking for pane maximization solutions inside tmux, existing hacks (e.g. the one described in the “tmux: Productive Mouse-Free Development” book) were too fragile: you could only minimize back a pane if you just maximized it. Creating new panes or new windows in between the maximize/minimize sequence would break it all.

The idea is to create a new window with a single pane that dies immediately. Once dead that new pane is swapped with the pane to be maximized, effectively exchanging size and position. The mapping between maximized and placeholder panes is kept inside pane titles (which are unused by tmux itself and default to the hostname upon pane creation).

That hack allows you to maximize different panes to different windows and to minimize them back at will, at any time. You can even split further a window that got created for the purpose of hosting a maximized pane, then later minimize that pane back.

I also wanted the window title to change dynamically to reflect that the current pane has been maximized to a new window. This is achieved by abusing tmux’s parsing of exec commands. If you didn’t renamed the current window, the title will change to “ maximized[dead] ”: that’s the best I could hack to indicate that the current pane has been maximized to a new window.