zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH 1/2] _tmux: Complete only attached sessions for detach-session.
Date: Fri, 18 Aug 2017 04:23:44 +0000	[thread overview]
Message-ID: <20170818042345.30778-1-danielsh@tarpaulin.shahaf.local2> (raw)

---
 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}"


             reply	other threads:[~2017-08-18  4:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18  4:23 Daniel Shahaf [this message]
2017-08-18  4:23 ` [PATCH 2/2] _tmux: Complete detached sessions first for attach-session Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170818042345.30778-1-danielsh@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).