Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sometimes it would be very useful to maximize a pane in tmux and then restore it to it's previous size.

I've been reading the manual and I can't find a way. What I've come up with is that I could bind a key to resize the pane to "max" width, and another key to restore it to some predefined width.

Of course this has its drawbacks, so I'm wondering if anyone has a better idea.

share|improve this question

9 Answers 9

up vote 28 down vote accepted

Another option could be to use break-pane followed by join-pane. From the man page:

break-pane [-d] [-t target-pane]
                   (alias: breakp)
             Break target-pane off from its containing window to make it the
             only pane in a new window.  If -d is given, the new window does
             not become the current window.

join-pane [-dhv] [-l size | -p percentage] [-s src-pane] [-t dst-pane]
                   (alias: joinp)
             Like split-window, but instead of splitting dst-pane and creating
             a new pane, split it and move src-pane into the space.  This can
             be used to reverse break-pane.

So you could select your pane and do break-pane and then once your done with the maximised version, you could re-join it with join-pane - might need some default arguments to put it back in place, or just rearrange afterwards.

Note that join-pane appears to be in tmux 1.3 but not 1.1. (Not sure about 1.2, sorry).

And just to mention that terminator (a GUI (GTK based) terminal multiplexer) can do the zoom thing. (Ctrl-Shift-X is the default keybinding). Of course it doesn't do lots of things that tmux does ...

share|improve this answer
9  
As of version 1.8 there is a better solution (see Tyler Holien's answer). –  momeara Oct 30 '13 at 13:19

This is now a native tmux feature.

Version 1.8 saw the addition of the -Z flag to resize-pane. From the man page:

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

It's bound to tmux-prefix-z by default on my installation (via Homebrew on OS X).

share|improve this answer
1  
Installed 1.8 just for this. Thanks! –  thameera Apr 16 '13 at 14:02
2  
Much, much simpler than so many other solutions. –  EOL Jun 9 '13 at 14:26
1  
Best solution as of now. –  jdvauguet Jun 19 '13 at 8:15
7  
someone with adequate privilages should make this the answer. It is inconceivable that someone would still be using a version of tmux other than the latest. –  Jay Jul 9 '13 at 13:14
    
thanks, you have made my day (or week ;)) –  Sławosz Feb 3 at 12:57

So I know you asked this a while ago ... but I didn't switch from screen until today!

I ran into the same problem, here is how I solved it:

unbind +
bind + new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom
unbind -
bind - last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom

If your workflow is like mine (i.e. you maximize a window, do some work, then immediately unmaximize it) this should work great for you.

share|improve this answer
    
(In case it wasn't clear, this maintains the layout in your original window...after maximizing and un-maximizing, it's exactly the same.) –  Ryan Nov 15 '11 at 20:22
1  
This is a great solution. Thank you for posting Ryan!! –  Alfred Fazio Dec 1 '11 at 19:14
    
perfect man! I'm sharing this :) –  DallaRosa Mar 24 '12 at 16:48
2  
Any idea how I could map the same keystroke to both? Something like bind c-m select-window -t tmux-zoom ? <minimize> : <maximize>. But now I want to define this function somewhere else, for the sake of cleanliness, and just bind c-m :max_or_min. Is that possible? I'm finding it hard to search for. (I find I often hit the wrong command and end up creating additional, empty 'tmux-zoom' windows.) –  chadoh Apr 3 '12 at 13:44
5  
This worked for me only when I removed 'clear && echo TMUX ZOOM && read' from maximize. –  Epeli Apr 8 '12 at 18:32

Improved zoomer. Now one can zoom multiple panes, even hierarchically. After doing the below and reloading your tmux server (Ctrl-r in my case) you will have your x key bound to zoom in and zoom out a pane. zoom-in is achieved by opening pane in a new window, and zoom-out is achieved by taking a pane back to its original window. If you end up splitting the zoom-in window, you will be able to zoom into the panes of the zoom-in window and zoom-out back to the zoom-in window. zoom-out happens only if you are in a zoom-in window containing a single pane.

Add following to end of your ~/.tmux.conf

~$ grep "bind x" ~/.tmux.conf
unbind x
bind x run ". ~/.tmux/zoom"

Add following file

~$ cat ~/.tmux/zoom
#!/bin/bash -f
currentwindow=`tmux list-window | tr '\t' ' ' | sed -n -e '/(active)/s/^[^:]*: *\([^ ]*\) .*/\1/gp'`;
currentpane=`tmux list-panes | sed -n -e '/(active)/s/^\([^:]*\):.*/\1/gp'`;
panecount=`tmux list-panes | wc | sed -e 's/^ *//g' -e 's/ .*$//g'`;
inzoom=`echo $currentwindow | sed -n -e '/^zoom/p'`;
if [ $panecount -ne 1 ]; then
    inzoom="";
fi
if [ $inzoom ]; then
    lastpane=`echo $currentwindow | rev | cut -f 1 -d '@' | rev`;
    lastwindow=`echo $currentwindow | cut -f 2- -d '@' | rev | cut -f 2- -d '@' | rev`;
    tmux select-window -t $lastwindow;
    tmux select-pane -t $lastpane;
    tmux swap-pane -s $currentwindow;
    tmux kill-window -t $currentwindow;
else
    newwindowname=zoom@$currentwindow@$currentpane;
    tmux new-window -d -n $newwindowname;
    tmux swap-pane -s $newwindowname;
    tmux select-window -t $newwindowname;
fi
share|improve this answer
3  
Only a single upvote?! This answer is awesome! Works very well, introduces nice new functionality which now completely replaces the bloaty 'terminator' program I used to use. –  sillyMunky Aug 27 '12 at 10:49
    
+1 This is really good! By far the best working solution I've come across so far! Thanks!! –  armandino Nov 8 '12 at 6:07
    
I concur. This works, and is more than awesome. It's screen++ –  Brad Parks Mar 6 '13 at 3:28
    
+1. This works great but it's a fraction of a second (~0.8s) slower than @Ryan's answer above, at least on my system. Not a big deal, but I wonder if there is a way to make it faster –  user815423426 Mar 6 '13 at 15:55
    
Beautiful indeed. I love the special pane names (zoom@…), which are useful reminders, and the single "x" zoom in/out command. –  EOL Jun 9 '13 at 14:26

I did this to maximize/minimize with the same keystroke:

bind C-k run "if [[ $(tmux list-window) =~ ZOOM ]]; then tmux last-window; tmux swap-pane -s ZOOM.1; tmux kill-window -t ZOOM; else tmux new-window -d -n ZOOM; tmux swap-pane -s ZOOM.1; tmux select-window -t ZOOM;fi"
share|improve this answer

Also for me work without 'clear && echo TMUX ZOOM && read'. With this snippet every time I minimize one pane from first window disappear.

share|improve this answer

This solution is the only one I've found that works:

https://github.com/jipumarino/tmux-zoom

share|improve this answer

For those who can't go with tmux 1.8 or prefer a longer maximized state, I published a tmux script that works with tmux 1.6+.

Hope that helps.

share|improve this answer

I am on Ubuntu 12.04 and also needed this feature. Since tmux 1.8 there is native support for zoom toggling using tmux-prefix z. Since we probably won't see tmux 1.8 in 12.04 I compiled tmux 1.8 from source on another dev computer, renamed it to _tmux-1.8 and just copied the 1.8 binary to /usr/bin/_tmux-1.8 and edited .bash_aliases -> alias tmux='_tmux-1.8'.

I haven't noticed any problems using this quick and dirty method and when/if tmux 1.8 comes to 12.04 I haven't broken anything.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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