aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/pass.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bashrc.d/pass.bash')
-rw-r--r--bash/bashrc.d/pass.bash17
1 files changed, 12 insertions, 5 deletions
diff --git a/bash/bashrc.d/pass.bash b/bash/bashrc.d/pass.bash
index 0c5f2214..14a248e2 100644
--- a/bash/bashrc.d/pass.bash
+++ b/bash/bashrc.d/pass.bash
@@ -7,9 +7,16 @@ fi
# distribution
_pass()
{
+ # If we can't read the password directory, just bail
+ local passdir=${PASSWORD_STORE_DIR:-$HOME/.password-store}
+ if [[ ! -r "$passdir" ]] ; then
+ return 1
+ fi
+
+ # Iterate through list of .gpg paths, extension stripped, null-delimited,
+ # and filter them down to the ones matching the completing word (compgen
+ # doesn't seem to do this properly with a null delimiter)
local word=${COMP_WORDS[COMP_CWORD]}
-
- # Iterate through list of .gpg paths, extension stripped, null-delimited
local entry
while read -d '' -r entry ; do
if [[ $entry == "$word"* ]] ; then
@@ -23,11 +30,11 @@ _pass()
shopt -u dotglob
shopt -s globstar
- # Figure out password directory and change into it
- passdir=${PASSWORD_STORE_DIR:-$HOME/.password-store}
- cd -- "$passdir" || return
+ # Change into password directory, or bail
+ cd -- "$passdir" 2>/dev/null || exit
# Gather the entries and remove their .gpg suffix
+ declare -a entries
entries=(**/*.gpg)
entries=("${entries[@]%.gpg}")