39 lines
1.2 KiB
Plaintext
Raw Normal View History

# bash completion for gpg -*- shell-script -*-
2009-05-27 18:32:47 +02:00
_gpg()
{
local cur prev words cword
_init_completion || return
2009-05-27 18:32:47 +02:00
case $prev in
-s|--sign|--clearsign|--decrypt-files|--load-extension)
2009-10-04 19:42:50 +02:00
_filedir
return 0
;;
--export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key)
2009-10-04 19:42:50 +02:00
# return list of public keys
COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \
sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p' \
-ne 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
-r|--recipient)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \
sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ) )
2011-11-09 23:28:11 +02:00
if [[ -e ~/.gnupg/gpg.conf ]]; then
COMPREPLY+=( $( compgen -W "$( sed -ne \
2009-10-04 19:42:50 +02:00
's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \
~/.gnupg/gpg.conf )" -- "$cur" ) )
2009-10-04 19:42:50 +02:00
fi
return 0
;;
esac
2009-05-27 18:32:47 +02:00
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$(gpg --dump-options)' -- "$cur" ) )
2011-04-04 22:14:39 +03:00
fi
2009-05-27 18:32:47 +02:00
} &&
complete -F _gpg -o default gpg
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh