diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:14:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:14:42 +0000 |
commit | 0bc58b66a4850cdb8458a86c3d9a2fc81de82aa3 (patch) | |
tree | ea0fe36eb5e6f40e0a1f765d44c4b0c0b2bfb089 /completions/gpg2 | |
parent | Initial commit. (diff) | |
download | bash-completion-0bc58b66a4850cdb8458a86c3d9a2fc81de82aa3.tar.xz bash-completion-0bc58b66a4850cdb8458a86c3d9a2fc81de82aa3.zip |
Adding upstream version 1:2.11.upstream/1%2.11upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/gpg2')
-rw-r--r-- | completions/gpg2 | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/completions/gpg2 b/completions/gpg2 new file mode 100644 index 0000000..cfa4023 --- /dev/null +++ b/completions/gpg2 @@ -0,0 +1,42 @@ +# gpg2(1) completion -*- shell-script -*- + +_gpg2() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --homedir) + _filedir -d + return + ;; + --sign | --clearsign | --options | --decrypt | -!(-*)s) + _filedir + return + ;; + --export | --sign-key | --lsign-key | --nrsign-key | --nrlsign-key | --edit-key) + # return list of public keys + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ + 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \ + 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur")) + return + ;; + --recipient | -!(-*)r) + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | + command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur")) + if [[ -e ~/.gnupg/gpg.conf ]]; then + COMPREPLY+=($(compgen -W "$(command sed -ne \ + 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ + ~/.gnupg/gpg.conf)" -- "$cur")) + fi + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$($1 --dump-options)' -- "$cur")) + fi +} && + complete -F _gpg2 -o default gpg2 + +# ex: filetype=sh |