Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _gpg: Use explicit UIDs for public / secret keys.
- X-seq: zsh-workers 42916
- From: doron.behar@xxxxxxxxx
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] _gpg: Use explicit UIDs for public / secret keys.
- Date: Sat, 2 Jun 2018 18:26:51 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=Tbf/RQLwixdUZmDNgZTjqgg7kQcIiPjFu8UzE1b66w0=; b=MdAvPTeE4JrDGXibeMhi7ORTfDQcwdeKOdetqQjJ5U2nASOYP8gLkTnDYBWc7TiEUq 7Y4JTv4f2Bt+0UVl/FZkPwYMC3qxPdce3dgqLifeD93LMPt5o9BOVuvNUZdDjsKFB3AL oxo5tJ2wj5s9UNu6dA11LiArO8yIZK0JU7T+NC23BokRUm7aF3EUe6nKJwiUjN6Uiy45 cGkv49qxVMlIvehlq5GaZdT6Coa/uwiBlqyPzX/Patz/9JzP3gMVxZabo1Lr7zExbajZ UvFZZP78NERpH6AmnnBmZ8NTWqLCws7PsJIv5UR3aPTK6TGVSWxEnPds+SrUBes/J/Rv kjeQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
From: Doron Behar <doron.behar@xxxxxxxxx>
Use the `--with-colons` option and parse the output.
---
Completion/Unix/Command/_gpg | 69 ++++++++++++++++++++++++++++++++----
1 file changed, 63 insertions(+), 6 deletions(-)
diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg
index 48a36eff2..7e707c5f6 100644
--- a/Completion/Unix/Command/_gpg
+++ b/Completion/Unix/Command/_gpg
@@ -206,20 +206,77 @@ 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
+ local public_keys=(${(@s.:.)$(_call_program public-keys eval IFS=$'\n' $words[1] $needed --list-public-keys --list-options no-show-photos --with-colons)})
+ local -a uids_and_emails
+ local i
+ for i in {1..${#public_keys[@]}}; do
+ if [[ ${public_keys[$i]} == "fpr" ]]; then
+ i=$((i + 1))
+ local j=$i
+ while [[ ${public_keys[$j]} != "fpr" ]] && [ $j -lt ${#public_keys[@]} ]; do
+ if [[ ${public_keys[$j]} =~ "@" ]]; then
+ local email="${public_keys[$j]}"
+ local uid=${public_keys[$i]}
+ uids_and_emails+=("${uid}":"${email}")
+ i=$j
+ break
+ fi
+ j=$((j + 1))
+ done
+ i=$j
+ fi
+ done
+ _describe -t public-keys 'public key' uids_and_emails
;;
secret-keys)
- _wanted secret-keys expl 'secret key' compadd \
- ${${(Mo)$(_call_program secret-keys $words[1] $needed --list-secret-keys --list-options no-show-photos):%<*>}//(<|>)/} && return
+ local secret_keys=(${(@s.:.)$(_call_program secret-keys eval IFS=$'\n' $words[1] $needed --list-secret-keys --list-options no-show-photos --with-colons)})
+ local -a uids_and_emails
+ local i
+ for i in {1..${#secret_keys[@]}}; do
+ if [[ ${secret_keys[$i]} == "fpr" ]]; then
+ i=$((i + 1))
+ local j=$i
+ while [[ ${secret_keys[$j]} != "fpr" ]] && [ $j -lt ${#secret_keys[@]} ]; do
+ if [[ ${secret_keys[$j]} =~ "@" ]]; then
+ local email="${secret_keys[$j]}"
+ local uid=${secret_keys[$i]}
+ uids_and_emails+=("${uid}":"${email}")
+ i=$j
+ break
+ fi
+ j=$((j + 1))
+ done
+ i=$j
+ fi
+ done
+ _describe -t secret-keys 'secret key' uids_and_emails
;;
ciphers)
_wanted ciphers expl cipher compadd \
${${(s.,.)${(M)${(f)${"$(_call_program ciphers $words[1] $needed --version)"}//,$'\n' #/, }:#Cipher*}#*:}# } && return
;;
(public-keyids)
- _wanted public-keys expl 'public keyid' \
- compadd ${(M)${${(f)"$(_call_program public-keyids $words[1] $needed --list-public-keys --list-options no-show-photos)"}## #}:#[0-9A-F](#c40)} && return
+ local public_keys=(${(@s.:.)$(_call_program public-keyids eval IFS=$'\n' $words[1] $needed --list-public-keys --list-options no-show-photos --with-colons)})
+ local -a uids_and_emails
+ local i
+ for i in {1..${#public_keys[@]}}; do
+ if [[ ${public_keys[$i]} == "fpr" ]]; then
+ i=$((i + 1))
+ local j=$i
+ while [[ ${public_keys[$j]} != "fpr" ]] && [ $j -lt ${#public_keys[@]} ]; do
+ if [[ ${public_keys[$j]} =~ "@" ]]; then
+ local email="${public_keys[$j]}"
+ local uid=${public_keys[$i]}
+ uids_and_emails+=("${uid}":"${email}")
+ i=$j
+ break
+ fi
+ j=$((j + 1))
+ done
+ i=$j
+ fi
+ done
+ _describe -t public-keyids 'public keyids' uids_and_emails
;;
(option-list)
_sequence _wanted options expl option \
--
2.17.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author