zsh-workers
 help / color / mirror / code / Atom feed
From: doron.behar@gmail.com
To: zsh-workers@zsh.org
Subject: [PATCH 1/1] _gpg: Use explicit UIDs for state = public keys.
Date: Sat, 26 May 2018 18:16:28 +0300	[thread overview]
Message-ID: <20180526151628.17983-2-doron.behar@gmail.com> (raw)
In-Reply-To: <20180526151628.17983-1-doron.behar@gmail.com>

From: Doron Behar <doron.behar@gmail.com>

Use the `--with-colons` option and parse the output while IFS=":"
according to the output format.
---
 Completion/Unix/Command/_gpg | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg
index 48a36eff2..71fa7667d 100644
--- a/Completion/Unix/Command/_gpg
+++ b/Completion/Unix/Command/_gpg
@@ -206,8 +206,19 @@ fi
 
 case "$state" in
   public-keys)
-    _wanted public-keys expl 'public key' \
-	compadd ${${(Mo)$(_call_program public-keys $words[1] $needed --list-public-keys --list-options no-show-photos):%<*>}//(<|>)/} && return
+    OLDIFS="${IFS}"
+    IFS=":"
+    public_keys=($($words[1] $needed --list-public-keys --list-options no-show-photos --with-colons))
+    for i in {1..${#public_keys[@]}}; do
+      if [[ ${public_keys[$i]} =~ "fpr" ]] && [[ ${public_keys[$((i + 19))]} =~ "@" ]] ; then
+        # +9 is the uid
+        # +19 is the description
+        uids_and_emails+=(${public_keys[$((i + 9))]}":"${public_keys[$((i + 19))]})
+        i=$((i+20))
+      fi
+    done
+    _describe uids uids_and_emails
+    IFS="${OLDIFS}"
   ;;
   secret-keys)
     _wanted secret-keys expl 'secret key' compadd \
-- 
2.17.0


  reply	other threads:[~2018-05-26 15:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-26 15:16 [PATCH 0/1] *** Small improvement for gpg completion *** doron.behar
2018-05-26 15:16 ` doron.behar [this message]
2018-05-26 16:25   ` [PATCH 1/1] _gpg: Use explicit UIDs for state = public keys Daniel Shahaf
2018-05-29 14:11     ` Doron Behar
2018-05-30 19:04       ` Daniel Shahaf
2018-06-02 15:08         ` Doron Behar

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=20180526151628.17983-2-doron.behar@gmail.com \
    --to=doron.behar@gmail.com \
    --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).