Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 1/1] _gpg: Use explicit UIDs for state = public keys.



From: Doron Behar <doron.behar@xxxxxxxxx>

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



Messages sorted by: Reverse Date, Date, Thread, Author