mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 22:21:15 -03:00
completions/gpg: list only secret for gpg options that manage secret keys
Some GPG options work only with private keys but our completions suggest all keys. Modify `__fish_complete_gpg_user_id and __fish_complete_gpg_key_id` to take an optional argument for the "key type" to override `--list-keys` with like `--list-secret-keys` for the appropriate options. Closes #8712
This commit is contained in:
committed by
Johannes Altmanninger
parent
5af1e64441
commit
63d7386a36
@@ -1,16 +1,18 @@
|
||||
# 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
|
||||
function __fish_complete_gpg_key_id -d 'Complete using gpg key ids' -a __fish_complete_gpg_command list_arg
|
||||
# Use user id as description
|
||||
set -l keyid
|
||||
$__fish_complete_gpg_command --list-keys --with-colons | while read -l garbage
|
||||
set -q list_arg[1]; or set list_arg --list-keys
|
||||
$__fish_complete_gpg_command $list_arg --with-colons | while read -l garbage
|
||||
switch $garbage
|
||||
case "uid*"
|
||||
# Extract user ids (note: gpg escapes colons as '\x3a')
|
||||
set -l __uid (string split ":" -- $garbage)
|
||||
set -l uid (string replace -a '\x3a' ':' -- $__uid[10])
|
||||
printf "%s\t%s\n" $keyid $uid
|
||||
case "pub*"
|
||||
# NOTE key is preceded by "sec" instead of "pub" when listing secret keys
|
||||
case "pub*" "sec*"
|
||||
# Extract key fingerprints (no subkeys)
|
||||
set -l __pub (string split ":" -- $garbage)
|
||||
set keyid $__pub[5]
|
||||
|
||||
Reference in New Issue
Block a user