Close all terminal tabs except the current one (iTerm2 et al.)
Just append following snippet to your .zshrc
(or .bashrc
):
:only() {
PROG='!'"/^$$|ack/&&/$(basename $SHELL)"'$/{print$2}'
ps -ao pid,ppid,comm= | awk "$PROG" | xargs kill
}
if [[ "$SHELL" == *zsh ]]; then
zle -N :only
bindkey "^Wo" :only
bindkey "^W^O" :only
fi
Now you can use both :only
command and C-w o
shourtcut to close all windows except current one.
Disclaimer: shortcut won't work on bash because I didn't find way to bind
such sequence of characters (C-w o
). You can use some simpler binding (C-o
doesn't work for me anyway):
bind '"\C-w": ":only && clear\n"'
btw. it works for panels too
Written by Adam Stankiewicz
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#