fix(tmux): Remove redundant -t flag

This commit is contained in:
detroyejr
2024-03-11 17:30:30 -04:00
parent fe6977245d
commit ab33a04e95

View File

@@ -59,11 +59,11 @@ function _build_tmux_alias {
# ALIAS COMPLETION (Modified from https://github.com/zsh-users/zsh)
_tmux-attach-session() {
local sessions
sessions=(${(f)"$(tmux list-session)"})
[[ -n ${tmux_describe} ]] && print "attach or switch to a session" && return
# If no flag is given, complete with session names.
local sessions
sessions=(${(f)"$(tmux list-session)"})
if (( CURRENT == 2 )); then
_alternative \
'commands:: _describe -t sessions "tmux session" sessions'
@@ -72,19 +72,17 @@ _tmux-attach-session() {
if [[ $words[1] =~ ta ]]; then
_arguments -s \
'1:sessions' \
'1:session' \
'-c+[specify working directory for the session]:directory:_directories' \
'-d[detach other clients attached to target session]' \
'-f+[set client flags]: :_tmux_client_flags' \
'-r[put the client into read-only mode]' \
'-t+[specify target session]:target session: __tmux-sessions-separately' \
"-E[don't apply update-environment option]" \
'-x[with -d, send SIGHUP to the parent of the attached client]'
elif [[ $words[1] = "tkss" ]]; then
_arguments -s \
'1:sessions' \
'1:session' \
'-a[kill all session except the one specified by -t]' \
'-t+[specify target session]:session:__tmux-sessions' \
'-C[clear alerts (bell, activity, silence) in all windows linked to the session]'
fi
@@ -96,24 +94,6 @@ _tmux_client_flags() {
'pause-after:time (seconds)' read-only wait-exit
}
__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
}
alias tksv='tmux kill-server'
alias tl='tmux list-sessions'
alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'