tmux : support multiple args for tk.

This commit is contained in:
Dmitry Voronin 2023-11-19 22:12:18 +03:00
parent 0436da5934
commit fac60dda30

View file

@ -43,15 +43,15 @@ tn()
# kill specified session or default one. # kill specified session or default one.
tk() tk()
{ {
local name="$1"
# set default name. # set default name.
if [[ "$name" = "" ]]; then if [[ "${1}" = "" ]]; then
name="main" 1="main"
fi fi
# call tmux. # call tmux.
tmux kill-session -t "$name" for name in "$@"; do
tmux kill-session -t "${name}"
done
} }
# kill all sessions. # kill all sessions.
@ -65,15 +65,21 @@ tka()
} }
# autocompletes. # autocompletes.
_tmux_sessions() _complete_tmux_session()
{ {
_autocomplete_first "$(tmux list-sessions 2> /dev/null | sed -e 's/:.*//')" _autocomplete_first "$(tmux list-sessions 2> /dev/null | sed -e 's/:.*//')"
} }
_tmux_names() _complete_tmux_sessions()
{
_autocomplete "$(tmux list-sessions 2> /dev/null | sed -e 's/:.*//')"
}
_complete_tmux_name()
{ {
_autocomplete_first "${PWD##*/}" $(ls --classify | grep /$ | sed -e 's/\/$//') _autocomplete_first "${PWD##*/}" $(ls --classify | grep /$ | sed -e 's/\/$//')
} }
complete -F _tmux_sessions ta tk complete -F _complete_tmux_session ta
complete -o nosort -F _tmux_names tr tn complete -F _complete_tmux_sessions tk
complete -o nosort -F _complete_tmux_name tr tn