Created
July 11, 2012 13:56
-
-
Save tacahiroy/3090513 to your computer and use it in GitHub Desktop.
kill tmux windows except active window (zsh, bash)
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() { | |
local pat=$1 | |
local windows="`tmux list-windows -F '#{window_index}:#{window_name}-#{window_active}'`" | |
[ `echo "${windows}" | wc -l | tr -d ' ' | grep '^1$'` ] && return | |
local 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