Created
July 12, 2012 01:21
-
-
Save tacahiroy/3095023 to your computer and use it in GitHub Desktop.
kill tmux windows except active window (ksh)
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
function tm_kill_other_windows { | |
pat=$1 | |
windows="`tmux list-windows -F '#{window_index}:#{window_name}-#{window_active}'`" | |
[ `echo "${windows}" | wc -l | tr -d ' ' | grep '^1$'` ] && return | |
cur_win_nbr=`echo "${windows}" | grep '\-1$' | grep -o '^[0-9]\+'` | |
windows=`echo "${windows}" | grep -v "^${cur_win_nbr}:"` | |
windows=`echo "${windows}" | grep "^[0-9]\+:.*${pat}.*-[01]$"` | |
for i in `echo "${windows}" | grep -o '^[0-9]\+'`; do | |
tmux kill-window -t ${i} | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment