-
-
Save epleterte/2786476 to your computer and use it in GitHub Desktop.
robust tmux zoom toggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# zoom | |
unbind ^M | |
bind ^M new-window -d -n zoom 'tmux-zoom' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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