diff options
author | Brian Mattern <rephorm@rephorm.com> | 2012-09-22 08:47:30 -0700 |
---|---|---|
committer | Brian Mattern <rephorm@rephorm.com> | 2012-09-22 08:47:30 -0700 |
commit | 3f1ea67c5647c51001642e93121836f96075f81c (patch) | |
tree | f55b6c0d5aa5de7807029eb84f1e803fb32b10c0 /contrib | |
parent | 206e28caa3737f87e8efb1be38294d3279cbed77 (diff) | |
download | pass-3f1ea67c5647c51001642e93121836f96075f81c.tar.gz pass-3f1ea67c5647c51001642e93121836f96075f81c.tar.bz2 pass-3f1ea67c5647c51001642e93121836f96075f81c.zip |
simplify logic slightly
Diffstat (limited to '')
-rw-r--r-- | contrib/pass.bash-completion | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/contrib/pass.bash-completion b/contrib/pass.bash-completion index a7d0f28..72f2abb 100644 --- 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 |