password-store

Simple password manager using gpg and ordinary unix directories
git clone https://git.zx2c4.com/password-store
Log | Files | Refs | README | LICENSE

commit 3f1ea67c5647c51001642e93121836f96075f81c
parent 206e28caa3737f87e8efb1be38294d3279cbed77
Author: Brian Mattern <rephorm@rephorm.com>
Date:   Sat, 22 Sep 2012 08:47:30 -0700

simplify logic slightly

Diffstat:
Mcontrib/pass.bash-completion | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/contrib/pass.bash-completion b/contrib/pass.bash-completion @@ -15,20 +15,23 @@ _pass_complete_entries () { if [[ $item == $prefix.* ]]; then continue fi - # append / to directories and recursively expand single-entry dir - while [[ -d $item ]]; do - item="$item/" - if [[ ${#items[@]} -eq 1 && $autoexpand -eq 1 ]]; then - local subitems=($(compgen -f $item)) + + # if there is a unique match, and it is a directory with one entry + # autocomplete the subentry as well (recursively) + if [[ ${#items[@]} -eq 1 && $autoexpand -eq 1 ]]; then + while [[ -d $item ]]; do + local subitems=($(compgen -f "$item/")) if [[ ${#subitems[@]} -eq 1 ]]; then item="${subitems[0]}" else break fi - else - break - fi - done + done + fi + + # append / to directories + [[ -d $item ]] && item="$item/" + item="${item%$suffix}" COMPREPLY+=("${item#$prefix}") done