2019-09-24 22:31:44 +00:00
|
|
|
# Helper function for contextual autocompletion of GPG key ids
|
|
|
|
|
|
|
|
function __fish_complete_gpg_key_id -d 'Complete using gpg key ids' -a __fish_complete_gpg_command
|
|
|
|
# Use user id as description
|
|
|
|
set -l keyid
|
2020-05-15 05:14:54 +00:00
|
|
|
$__fish_complete_gpg_command --list-keys --with-colons | while read -l garbage
|
2019-09-24 22:31:44 +00:00
|
|
|
switch $garbage
|
|
|
|
case "uid*"
|
2020-02-17 13:12:27 +00:00
|
|
|
# Extract user ids (note: gpg escapes colons as '\x3a')
|
2020-01-21 16:11:36 +00:00
|
|
|
set -l __uid (string split ":" -- $garbage)
|
2020-05-15 05:56:06 +00:00
|
|
|
set -l uid (string replace -a '\x3a' ':' -- $__uuid[10])
|
2019-09-24 22:31:44 +00:00
|
|
|
printf "%s\t%s\n" $keyid $uid
|
|
|
|
case "pub*"
|
2020-02-17 13:12:27 +00:00
|
|
|
# Extract key fingerprints (no subkeys)
|
2020-01-21 16:11:36 +00:00
|
|
|
set -l __pub (string split ":" -- $garbage)
|
|
|
|
set keyid $__pub[5]
|
2019-09-24 22:31:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|