2011-11-01 22:14:45 +02:00
|
|
|
# bash completion for gpg -*- shell-script -*-
|
2009-05-27 18:32:47 +02:00
|
|
|
|
|
|
|
_gpg()
|
|
|
|
{
|
2011-04-20 17:02:27 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2009-05-27 18:32:47 +02:00
|
|
|
|
2009-12-30 00:39:59 +01:00
|
|
|
case $prev in
|
2009-11-22 11:43:26 +01:00
|
|
|
-s|--sign|--clearsign|--decrypt-files|--load-extension)
|
2009-10-04 19:42:50 +02:00
|
|
|
_filedir
|
|
|
|
return 0
|
|
|
|
;;
|
2012-11-03 23:15:20 +04:00
|
|
|
--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 | \
|
2009-11-04 00:16:06 +02:00
|
|
|
sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p' \
|
|
|
|
-ne 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-r|--recipient)
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \
|
2013-02-17 23:49:30 +02:00
|
|
|
sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ) )
|
2011-11-09 23:28:11 +02:00
|
|
|
if [[ -e ~/.gnupg/gpg.conf ]]; then
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $( compgen -W "$( sed -ne \
|
2009-10-04 19:42:50 +02:00
|
|
|
's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \
|
2013-02-17 23:49:30 +02:00
|
|
|
~/.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
|
2009-10-18 22:12:37 +03:00
|
|
|
COMPREPLY=( $( compgen -W '$(gpg --dump-options)' -- "$cur" ) )
|
2011-04-04 22:14:39 +03:00
|
|
|
fi
|
2009-05-27 18:32:47 +02:00
|
|
|
} &&
|
2009-10-22 12:04:29 +03:00
|
|
|
complete -F _gpg -o default gpg
|
2009-10-01 20:54:51 +03:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|