mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-05 11:01:13 +02:00
41567: _tmux: Complete detached sessions first for attach-session.
This commit is contained in:
parent
1e44c649a4
commit
73514c40f6
2 changed files with 23 additions and 1 deletions
|
@ -1,5 +1,8 @@
|
|||
2017-08-30 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||
|
||||
* 41567: Completion/Unix/Command/_tmux: Complete detached
|
||||
sessions first for attach-session.
|
||||
|
||||
* 41566: Completion/Unix/Command/_tmux: Complete only attached
|
||||
sessions for detach-session.
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ _tmux-attach-session() {
|
|||
'-c+[specify working directory for the session]:directory:_directories' \
|
||||
'-d[detach other clients attached to target session]' \
|
||||
'-r[put the client into read-only mode]' \
|
||||
'-t+[specify target session]:target session:__tmux-sessions' \
|
||||
'-t+[specify target session]:target session: __tmux-sessions-separately' \
|
||||
"-E[don't apply update-environment option]"
|
||||
}
|
||||
|
||||
|
@ -1373,6 +1373,25 @@ function __tmux-sessions-attached() {
|
|||
_describe -t sessions 'attached sessions' sessions "$@"
|
||||
}
|
||||
|
||||
# Complete attached-sessions and detached-sessions as separate tags.
|
||||
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 sessions' detached_sessions "$@" && ret=0
|
||||
_requested attached-sessions && _describe -t attached-sessions 'attached sessions' attached_sessions "$@" && ret=0
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
function __tmux-socket-name() {
|
||||
local expl sdir
|
||||
local curcontext="${curcontext}"
|
||||
|
|
Loading…
Reference in a new issue