summaryrefslogtreecommitdiffstats
path: root/completions/gpg
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:14:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:14:42 +0000
commit0bc58b66a4850cdb8458a86c3d9a2fc81de82aa3 (patch)
treeea0fe36eb5e6f40e0a1f765d44c4b0c0b2bfb089 /completions/gpg
parentInitial commit. (diff)
downloadbash-completion-0bc58b66a4850cdb8458a86c3d9a2fc81de82aa3.tar.xz
bash-completion-0bc58b66a4850cdb8458a86c3d9a2fc81de82aa3.zip
Adding upstream version 1:2.11.upstream/1%2.11upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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