Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _gpg: Use explicit UIDs for state = public keys.
- X-seq: zsh-workers 43059
- From: doron.behar@xxxxxxxxx
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] _gpg: Use explicit UIDs for state = public keys.
- Date: Mon, 18 Jun 2018 22:47:48 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=Skdj1ejJ/ODSrmJ/37AZwxcOpIWmGUwID+OrMRTUfbs=; b=tw6gWwkjHTeKrrA+xL4MjpaQ1w9ypQVJEdvPbn3eyf1w2stkASLBO3GEvoqSvlTsxM JZWFtCTwo0gwoqxweV7gPNm0CG2NMibfq6ZtI8bKSXWIlUB8A15JvbmSgLPn17Psboca Fmf6YNuEFBn6JB38dvoj4II6I7T37PfCKEhaPFKzs8cstdhgrEdVwSgIssbxZyiSAtgj MX5yMwDXxS+3TulcAjVTG+WklzusnoGF/QdqjqrkwwSmWU9YDNo4KE5m+rOzfDtoA0Vh ZapaFHv7EHHKQpKpz4yys7RWfFaylGD8VbRNNxSAeugnPDIoudevY6OieRMG9Nmz3foc NBDA==
- 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 according to the
format specified in the documentation.
---
Completion/Unix/Command/_gpg | 62 ++++++++++++++++++++++++++++++++----
1 file changed, 55 insertions(+), 7 deletions(-)
diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg
index 48a36eff2..b35693d1f 100644
--- a/Completion/Unix/Command/_gpg
+++ b/Completion/Unix/Command/_gpg
@@ -206,20 +206,68 @@ 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_lines=(${(f)"$(_call_program public-keys ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"})
+ local -a uids emails
+ local i j parts current_uid
+ for (( i = 1; i < ${#public_keys_lines[@]}; ++i )); do
+ parts=("${(@s.:.)public_keys_lines[$i]}")
+ if [[ ${parts[1]} == "fpr" ]]; then
+ current_uid="${parts[10]}"
+ i=$((i + 1))
+ parts=("${(@s.:.)public_keys_lines[$i]}")
+ while [[ ${parts[1]} == "uid" ]]; do
+ uids+=("${current_uid}")
+ emails+=("${parts[10]}")
+ i=$((i + 1))
+ parts=("${(@s.:.)public_keys_lines[$i]}")
+ done
+ fi
+ done
+ _describe -t public-keys 'public key' emails uids
;;
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_lines=(${(f)"$(_call_program secret-keys ${(q)words[1]} ${(q)needed} --list-secret-keys --list-options no-show-photos --with-colons)"})
+ local -a uids emails
+ local i j parts current_uid
+ for (( i = 1; i < ${#secret_keys_lines[@]}; ++i )); do
+ parts=("${(@s.:.)secret_keys_lines[$i]}")
+ if [[ ${parts[1]} == "fpr" ]]; then
+ current_uid="${parts[10]}"
+ i=$((i + 1))
+ parts=("${(@s.:.)secret_keys_lines[$i]}")
+ while [[ ${parts[1]} == "uid" ]]; do
+ uids+=("${current_uid}")
+ emails+=("${parts[10]}")
+ i=$((i + 1))
+ parts=("${(@s.:.)secret_keys_lines[$i]}")
+ done
+ fi
+ done
+ _describe -t secret-keys 'secret key' emails uids
;;
ciphers)
_wanted ciphers expl cipher compadd \
- ${${(s.,.)${(M)${(f)${"$(_call_program ciphers $words[1] $needed --version)"}//,$'\n' #/, }:#Cipher*}#*:}# } && return
+ ${${(s.,.)${(M)${(f)${"$(_call_program ciphers ${(q)words[1]} ${(q)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_lines=(${(f)"$(_call_program public-keyids ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"})
+ local -a uids emails
+ local i j parts current_uid
+ for (( i = 1; i < ${#public_keys_lines[@]}; ++i )); do
+ parts=("${(@s.:.)public_keys_lines[$i]}")
+ if [[ ${parts[1]} == "fpr" ]]; then
+ current_uid="${parts[10]}"
+ i=$((i + 1))
+ parts=("${(@s.:.)public_keys_lines[$i]}")
+ while [[ ${parts[1]} == "uid" ]]; do
+ uids+=("${current_uid}")
+ emails+=("${parts[10]}")
+ i=$((i + 1))
+ parts=("${(@s.:.)public_keys_lines[$i]}")
+ done
+ fi
+ done
+ _describe -t public-keyids 'public key' emails uids
;;
(option-list)
_sequence _wanted options expl option \
--
2.17.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author