* [PATCH 1/2] _tmux: Complete only attached sessions for detach-session.
@ 2017-08-18 4:23 Daniel Shahaf
2017-08-18 4:23 ` [PATCH 2/2] _tmux: Complete detached sessions first for attach-session Daniel Shahaf
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Shahaf @ 2017-08-18 4:23 UTC (permalink / raw)
To: zsh-workers
---
Completion/Unix/Command/_tmux | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux
index 7999be3eb..48fe29aee 100644
--- a/Completion/Unix/Command/_tmux
+++ b/Completion/Unix/Command/_tmux
@@ -302,7 +302,7 @@ _tmux-detach-client() {
_arguments -s \
'-a[kill all clients except for the named by -t]' \
'-P[send SIGHUP to parent process]' \
- '-s+[specify target session and kill its clients]:session:__tmux-sessions' \
+ '-s+[specify target session and kill its clients]:session:__tmux-sessions-attached' \
'-t+[specify target client]:client:__tmux-clients'
}
@@ -1366,6 +1366,13 @@ function __tmux-sessions() {
_describe -t sessions 'sessions' sessions "$@"
}
+function __tmux-sessions-attached() {
+ local -a sessions
+ sessions=( ${${(f)"$(command tmux 2> /dev/null list-sessions)"}/:[ $'\t']##/:} )
+ sessions=( ${(M)sessions:#*"(attached)"} )
+ _describe -t sessions 'attached sessions' sessions "$@"
+}
+
function __tmux-socket-name() {
local expl sdir
local curcontext="${curcontext}"
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] _tmux: Complete detached sessions first for attach-session.
2017-08-18 4:23 [PATCH 1/2] _tmux: Complete only attached sessions for detach-session Daniel Shahaf
@ 2017-08-18 4:23 ` Daniel Shahaf
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Shahaf @ 2017-08-18 4:23 UTC (permalink / raw)
To: zsh-workers
---
Completion/Unix/Command/_tmux | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux
index 48fe29aee..f71f7c33e 100644
--- a/Completion/Unix/Command/_tmux
+++ b/Completion/Unix/Command/_tmux
@@ -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}"
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-18 4:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-18 4:23 [PATCH 1/2] _tmux: Complete only attached sessions for detach-session Daniel Shahaf
2017-08-18 4:23 ` [PATCH 2/2] _tmux: Complete detached sessions first for attach-session Daniel Shahaf
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).