From 206e28caa3737f87e8efb1be38294d3279cbed77 Mon Sep 17 00:00:00 2001 From: Brian Mattern Date: Sat, 22 Sep 2012 08:39:53 -0700 Subject: turn -o filenames back on only auto-expand if there is a single completion match --- contrib/pass.bash-completion | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'contrib') diff --git a/contrib/pass.bash-completion b/contrib/pass.bash-completion index 71bb12a..a7d0f28 100644 --- a/contrib/pass.bash-completion +++ b/contrib/pass.bash-completion @@ -10,15 +10,16 @@ _pass_complete_entries () { autoexpand=${1:-0} local IFS=$'\n' - for item in $(compgen -f $prefix$cur); do + local items=($(compgen -f $prefix$cur)) + for item in ${items[@]}; do if [[ $item == $prefix.* ]]; then continue fi - # append / to directories and recursively expand single-entry dirs + # append / to directories and recursively expand single-entry dir while [[ -d $item ]]; do item="$item/" - if [[ $autoexpand -eq 1 ]]; then - subitems=($(compgen -f $item)) + if [[ ${#items[@]} -eq 1 && $autoexpand -eq 1 ]]; then + local subitems=($(compgen -f $item)) if [[ ${#subitems[@]} -eq 1 ]]; then item="${subitems[0]}" else @@ -29,11 +30,6 @@ _pass_complete_entries () { fi done item="${item%$suffix}" - item="${item// /\ }" - item="${item//'/\'}" - item="${item//\(/\(}" - item="${item//)/\)}" - item="${item//&/\&}" COMPREPLY+=("${item#$prefix}") done } @@ -79,4 +75,4 @@ _pass() fi } -complete -o nospace -F _pass pass +complete -o filenames -o nospace -F _pass pass -- cgit v1.2.3