aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/gpg.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bash_completion.d/gpg.bash')
-rw-r--r--bash/bash_completion.d/gpg.bash17
1 files changed, 17 insertions, 0 deletions
diff --git a/bash/bash_completion.d/gpg.bash b/bash/bash_completion.d/gpg.bash
new file mode 100644
index 00000000..c2f08415
--- /dev/null
+++ b/bash/bash_completion.d/gpg.bash
@@ -0,0 +1,17 @@
+# Completion for gpg with long options
+_gpg() {
+
+ # Bail if no gpg(1)
+ hash gpg 2>/dev/null || return 1
+
+ # Bail if not completing an option
+ [[ ${COMP_WORDS[COMP_CWORD]} == --* ]] || return 1
+
+ # Generate completion reply from gpg(1) options
+ local option
+ while read -r option ; do
+ [[ $option == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
+ COMPREPLY[${#COMPREPLY[@]}]=$option
+ done < <(gpg --dump-options 2>/dev/null)
+}
+complete -F _gpg -o default gpg