rewrite __fish_complete_gpg_key_id to produce better output

This commit is contained in:
LawAbidingCactus 2019-09-08 19:01:44 +00:00 committed by David Adam
parent 8e0aa03c4a
commit d2e9ee290c

View file

@ -28,16 +28,18 @@ function __fish_complete_gpg_user_id -d "Complete using gpg user ids"
end
function __fish_complete_gpg_key_id -d 'Complete using gpg key ids'
# Use user_id as the description
set -l lastid
# Use user id as description
set -l keyid
gpg --list-keys --with-colons | while read garbage
switch $garbage
# Extract user ids
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 fingerprints (no subkeys)
case "pub*"
echo $garbage | cut -d ":" -f 5 | read keyid
end
printf "%s\t%s\n" $fingerprint $lastid
end
end