summaryrefslogtreecommitdiffstats
path: root/completions/gpg
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--completions/gpg38
-rw-r--r--completions/gpg242
-rw-r--r--completions/gpgv46
3 files changed, 126 insertions, 0 deletions
diff --git a/completions/gpg b/completions/gpg
new file mode 100644
index 0000000..f0ca884
--- /dev/null
+++ b/completions/gpg
@@ -0,0 +1,38 @@
+# bash completion for gpg -*- shell-script -*-
+
+_gpg()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ case $prev in
+ --sign | --clearsign | --decrypt-files | --load-extension | -!(-*)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 _gpg -o default gpg
+
+# ex: filetype=sh
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
diff --git a/completions/gpgv b/completions/gpgv
new file mode 100644
index 0000000..29315c9
--- /dev/null
+++ b/completions/gpgv
@@ -0,0 +1,46 @@
+# gpgv(1) completion -*- shell-script -*-
+
+_gpgv()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ case $prev in
+ --help | --version | --weak-digest | --*-fd | -!(-*)[?h]*)
+ return
+ ;;
+ --keyring)
+ _filedir "@(gpg|kbx)"
+ return
+ ;;
+ --homedir)
+ _filedir -d
+ return
+ ;;
+ esac
+
+ local args
+ _count_args "" "--@(weak-digest|*-fd|keyring|homedir)"
+
+ if [[ $cur == -* && $args -eq 1 ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ return
+ fi
+
+ if ((args > 1)); then
+ if [[ ${COMP_LINE,,} == *.@(asc|sig|sign)\ * ]]; then
+ # Detached signature, only complete one arbitrary file arg and -
+ if ((args == 2)); then
+ COMPREPLY=($(compgen -W '-' -- "$cur"))
+ _filedir
+ fi
+ else
+ _filedir gpg
+ fi
+ else
+ _filedir "@(asc|gpg|sig|sign)"
+ fi
+} &&
+ complete -F _gpgv gpgv gpgv2
+
+# ex: filetype=sh