Skip to content

Instantly share code, notes, and snippets.

@tacahiroy
Created July 11, 2012 13:56
Show Gist options
  • Save tacahiroy/3090513 to your computer and use it in GitHub Desktop.
Save tacahiroy/3090513 to your computer and use it in GitHub Desktop.
kill tmux windows except active window (zsh, bash)
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