Created
October 16, 2012 20:56
-
-
Save pi8027/3901976 to your computer and use it in GitHub Desktop.
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 | |
# 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 |
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 | |
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry, I forgot to delete debug code. Please try again.