43 lines
1.3 KiB
Plaintext
Raw Normal View History

# gpg2(1) completion -*- shell-script -*-
2011-04-04 22:14:39 +03:00
_gpg2()
{
local cur prev words cword
_init_completion || return
case $prev in
2009-10-04 19:42:50 +02:00
--homedir)
_filedir -d
return 0
;;
-s|--sign|--clearsign|--options|--decrypt)
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 "$( gpg2 --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 "$( gpg2 --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-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$(gpg2 --dump-options)' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
fi
} &&
complete -F _gpg2 -o default gpg2
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh