From 5ef311735c74320483248da2ea68c38eb84ae768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 12 Sep 2018 23:47:41 +0300 Subject: bash-completion: detect whether to use gpg/gpg2 binary for complete keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Elan Ruusamäe --- src/completion/pass.bash-completion | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/completion/pass.bash-completion') 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})) } -- cgit v1.2.3