From d4a5ef170335e4c070335b7b5affab5bde61ec7e Mon Sep 17 00:00:00 2001 From: LawAbidingCactus Date: Sun, 8 Sep 2019 18:34:08 +0000 Subject: [PATCH] rewrite __fish_complete_gpg2_key_id to produce better output --- share/completions/gpg2.fish | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/share/completions/gpg2.fish b/share/completions/gpg2.fish index 5cb14552a..1097693f3 100644 --- a/share/completions/gpg2.fish +++ b/share/completions/gpg2.fish @@ -21,23 +21,25 @@ function __fish_complete_gpg2_user_id -d "Complete using gpg2 user ids" # gpg2 doesn't seem to like it when you use the whole key name as a - # completion, so we skip the part and use it a s a + # completion, so we skip the part and use it as a # description. # It also replaces colons with \x3a gpg2 --list-keys --with-colon | cut -d : -f 10 | sed -ne 's/\\\x3a/:/g' -e 's/\(.*\) <\(.*\)>/\1'\t'\2/p' end function __fish_complete_gpg2_key_id -d 'Complete using gpg2 key ids' - # Use user_id as the description - set -l lastid + # Use user id as description + set -l keyid gpg2 --list-keys --with-colons | while read garbage switch $garbage + # Extract user id case "uid*" - echo $garbage | cut -d ":" -f 10 | sed -e "s/\\\x3a/:/g" | read lastid - case "*" - echo $garbage | cut -d ":" -f 5 | read fingerprint + echo $garbage | cut -d ":" -f 10 | sed -e "s/\\\x3a/:/g" | read uid + printf "%s\t%s\n" $keyid $uid + # Extract key fingerprint (no subkeys) + case "pub*" + echo $garbage | cut -d ":" -f 5 | read keyid end - printf "%s\t%s\n" $fingerprint $lastid end end