aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/gpg.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-02 17:59:29 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-02 17:59:29 +1300
commit7d6fe8b1886f902f8ffbec2a9985fae9f91121cb (patch)
tree282fac0bb1809e726a373916c90260832ab23ced /bash/bash_completion.d/gpg.bash
parentReduce ud() completion to just dirnames (diff)
downloaddotfiles-7d6fe8b1886f902f8ffbec2a9985fae9f91121cb.tar.gz
dotfiles-7d6fe8b1886f902f8ffbec2a9985fae9f91121cb.zip
Overhaul Bash completion scripts
Some general changes: * Apply case sensitivity switching in more contexts, using a dynamically loaded helper function * Use array counters for appending to COMPREPLY where possible * Lots more short-circuiting to limit structural depth These changes are expansive and there will definitely be bugs.
Diffstat (limited to 'bash/bash_completion.d/gpg.bash')
-rw-r--r--bash/bash_completion.d/gpg.bash21
1 files changed, 12 insertions, 9 deletions
diff --git a/bash/bash_completion.d/gpg.bash b/bash/bash_completion.d/gpg.bash
index bfa2d1a9..c6f92676 100644
--- a/bash/bash_completion.d/gpg.bash
+++ b/bash/bash_completion.d/gpg.bash
@@ -1,7 +1,7 @@
# Completion for gpg(1) with long options
_gpg() {
- # Bail if no gpg(1)
+ # Needs gpg(1)
hash gpg 2>/dev/null || return
# Bail if not completing an option
@@ -11,13 +11,16 @@ _gpg() {
esac
# Generate completion reply from gpg(1) options
- local option
- while read -r option ; do
- case $option in
- "$2"*)
- COMPREPLY[${#COMPREPLY[@]}]=$option
- ;;
- esac
- done < <(gpg --dump-options 2>/dev/null)
+ local ci comp
+ while read -r comp ; do
+ COMPREPLY[ci++]=$comp
+ done < <(
+ gpg --dump-options 2>/dev/null |
+ while read -r option ; do
+ case $option in
+ ("$2"*) printf '%s\n' "$option" ;;
+ esac
+ done
+ )
}
complete -F _gpg -o bashdefault -o default gpg