47 lines
1.3 KiB
Plaintext
Raw Normal View History

2009-05-27 18:32:47 +02:00
# bash completion for gpg
have gpg || return
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|--lsignkey|--nrsignkey|--nrlsignkey|--editkey)
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" ))
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") )
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
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh