m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElan Ruusamäe <glen@pld-linux.org>2018-09-12 23:47:41 +0300
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-19 02:47:06 +0200
commit5ef311735c74320483248da2ea68c38eb84ae768 (patch)
tree29caee64706dcc4bbfe7f278aa30d561d17a0bd7
parente43b019042574d33510ca70f1f2389e414fa6102 (diff)
bash-completion: detect whether to use gpg/gpg2 binary for complete keys
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
-rw-r--r--src/completion/pass.bash-completion5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/completion/pass.bash-completion b/src/completion/pass.bash-completion
index 08f3401..95d3e1e 100644
--- a/src/completion/pass.bash-completion
+++ b/src/completion/pass.bash-completion
@@ -71,9 +71,12 @@ _pass_complete_folders () {
}
_pass_complete_keys () {
+ local GPG="gpg"
+ which gpg2 &>/dev/null && GPG="gpg2"
+
local IFS=$'\n'
# Extract names and email addresses from gpg --list-keys
- local keys="$(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')"
+ local keys="$($GPG --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')"
COMPREPLY+=($(compgen -W "${keys}" -- ${cur}))
}