Skip to content

Instantly share code, notes, and snippets.

@pi8027
Created October 16, 2012 20:56
Show Gist options
  • Save pi8027/3901976 to your computer and use it in GitHub Desktop.
Save pi8027/3901976 to your computer and use it in GitHub Desktop.
#!/bin/bash
# By Kazuhiko Sakaguchi. Public domain.
function usage_exit(){
cat <<EOT
Usage: $(echo $0 | sed "s/.*\///") [-adP] [-F format] [-t target-pane]
-a, -d, -P, -F format: these options are passed to tmux new-window
-t target-pane: specify target pane
EOT
exit $1
}
paneid=$(tmux display-message -p '#{pane_id}')
optflag_a=false
nwopts=
while getopts adPF:t: OPT ; do
case $OPT in
t ) paneid=$OPTARG ;;
a ) optflag_a=true ;;
d|P) nwopts="-$OPT $nwopts" ;;
F ) nwopts="-F $OPTARG $nwopts" ;;
* ) usage_exit -1 ;;
esac
done
paneid=$(tmux display-message -t $paneid -p '#{pane_id}' || exit -1)
winid=$(tmux display-message -t $paneid -p '#{window_id}')
pmtable=$(tmux showenv pmtable | sed 's/^pmtable=//')
$optflag_a && nwopts="-a -t $winid $nwopts"
if target=$(echo $pmtable | tr : "\n" | \
grep -E "(=|^)$paneid(=|$)" | head -n 1 | grep .) ; then
IFS== ; set -- $target ; IFS=' ' ; \
tmux swap-pane -t $2 -s $1 \; \
kill-pane -t $2 \; \
setenv pmtable "$(echo $pmtable | sed "s/:$target//")"
elif [ $(tmux list-panes -t $winid -F '' | wc -l) != 1 ] ; then
tmux new-window $nwopts "\"$0-sub\" $paneid"
fi
#!/bin/bash
# By Kazuhiko Sakaguchi. Public domain.
pmtable=$(tmux showenv pmtable | sed 's/^pmtable=//')
tmux swap-pane -s $1 -t $TMUX_PANE \; \
setenv pmtable "$pmtable:$1=$TMUX_PANE"
echo -ne '\033]2;DUMMY PANE\033\\'
stty intr undef
echo '********************'
echo '**** dummy pane ****'
echo '********************'
while true ; do read ; done
@iori-yja
Copy link

/usr/share/tmux

@pi8027
Copy link
Author

pi8027 commented Oct 17, 2012

tmux showenv tztable を tmux showenv | grep "^tztable=" に直すと tmux 1.7 以前でも動く気がしている。

@hiphamster
Copy link

This is a great idea, but for some reason it's not working for me - when i do ctl-a x i get a new pane with new empty history buffer (what you usually get when you do ctrl-a esc).

@pi8027
Copy link
Author

pi8027 commented Nov 6, 2012

Sorry, I forgot to delete debug code. Please try again.

@pi8027
Copy link
Author

pi8027 commented Nov 6, 2012

https://github.com/pi8027/pane-maximize
I created a pane-maximize repository on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment