1
0
Fork 0
dotfiles/.local/share/completions/_ta
2026-01-06 07:36:53 +03:00

26 lines
1,023 B
Text

#compdef ta
# from builtin _tmux
function __tmux-sessions-separately() {
local ret=1
local -a sessions detached_sessions attached_sessions
sessions=( ${${(f)"$(command tmux 2> /dev/null list-sessions)"}/:[ $'\t']##/:} )
detached_sessions=( ${sessions:#*"(attached)"} )
attached_sessions=( ${(M)sessions:#*"(attached)"} )
# ### This seems to work without a _tags loop but not with it. I suspect
# ### that has something to do with _describe doing its own _tags loop.
_tags detached-sessions attached-sessions
# Placing detached before attached means the default behaviour of this
# function better suits its only current caller, _tmux-attach-session().
_requested detached-sessions && _describe -t detached-sessions 'detached session' detached_sessions "$@" && ret=0
_requested attached-sessions && _describe -t attached-sessions 'attached session' attached_sessions "$@" && ret=0
return ret
}
_ta() {
_arguments '*:: : __tmux-sessions-separately'
}
_ta "$@"