Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Created April 14, 2012 09:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aaronjensen/2383108 to your computer and use it in GitHub Desktop.
Save aaronjensen/2383108 to your computer and use it in GitHub Desktop.
robust tmux zoom toggle
# zoom
unbind ^M
bind ^M new-window -d -n zoom 'tmux-zoom'
#!/bin/bash
if [ -f /tmp/tmux-unzoom ];
then
sh /tmp/tmux-unzoom
tmux kill-window -t $TMUX_PANE
else
# Don't zoom if there's only one pane
if [ `tmux list-panes | wc -l` -le 1 ];
then
tmux kill-window -t $TMUX_PANE
exit
fi
window=`tmux display-message -p "#I"`
pane=`tmux display-message -p "#P"`
tmux select-window -t $TMUX_PANE
zoom_window=`tmux display-message -p "#I"`
tmux swap-pane -s $window.$pane
echo "rm /tmp/tmux-unzoom && tmux select-window -t $TMUX_PANE \; select-pane -t $TMUX_PANE \; swap-pane -s $zoom_window.1 \; kill-window -t $zoom_window" > /tmp/tmux-unzoom
echo "Zoomed to window $zoom_window. Press enter to unzoom..."
# Sometimes read fails, so loop until we get a good one
while :
do
read 2> /dev/null
if [ $? -eq 0 ]
then
break
fi
done
sh /tmp/tmux-unzoom
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment