Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 2/2] _tmux: Complete detached sessions first for attach-session.
- X-seq: zsh-workers 41567
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 2/2] _tmux: Complete detached sessions first for attach-session.
- Date: Fri, 18 Aug 2017 04:23:45 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=n5iosOjIhB0nTkn4sTpLaXL4vT3Rx9x0ChVdQ0TbU AY=; b=OS0/OcKRSBI2mLwKY3FBmmYTzIKZ7J57jtaWL0A1m0JEOrINMCes6DqWj 5dbsM/NhhgJHklRMl/w34diFIsRAXj/9EEA2EG2oJCwz+DJREwEDpFAQSIlXGwYz McfZX1RCNtd1/rs4oD9xEtTWeUWSHYnIGLzsnJDj5Dj8deCzq2FWGjvEzFcS23gB FRbgGHaOq00vyG0fWyczOLohfAYef0cl3PKIN2+t4yq0mGYArupNpEA0UO5r+4Xu VJb3WkJx7WCZwCYeo2/LPNiAbOqX/wb1tkHum5+30CrzUvjqg7RoffBZ0styQmMU F//VwGdWYklvF5hspCMP2KxFrZJFQ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=n5iosOjIhB0nTkn4sTpLaXL4vT3Rx9x0ChVdQ0TbU AY=; b=Rtaxntvmhv3Xfxy+qyySNCwh+WEHPhaMCcdUIhqD1MDQyLH8b9DJ4mxxW 9DWsoos1w73fbSbdYds576KLDM8NWgeN1Wm++8W6d2sytj4/voi/vychRkIUtmdd x2+M7Ftqf7gFoa77BxoPhfDhX2p9vpjLBM2iRmL8RUSzU41t6xZ0UoPVnAl/jAiO kztOBy7zhrXE4dxIn80ijAP7OUgMfYXZnKy3daV/Ak5C74wH5dWcdVS7/v9NAd3h OGcHb9lpSAuK+07IKVCBpSr2RwM/2t/itm4OlfGJ1EaXmbsw1fmQ1nD1xWkIRyRQ Ujrt+wlOPeNmMOxu1TW495mhzGuGA==
- In-reply-to: <20170818042345.30778-1-danielsh@tarpaulin.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20170818042345.30778-1-danielsh@tarpaulin.shahaf.local2>
---
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}"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author