From 82951aafc58d0ea4529387bd180d28a664506743 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 11 Mar 2017 21:16:32 -0500 Subject: add ls-files subcommand, allow showing files other than PKGBUILD --- shell/bash-completion | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'shell/bash-completion') diff --git a/shell/bash-completion b/shell/bash-completion index cdd7f92..339134f 100644 --- a/shell/bash-completion +++ b/shell/bash-completion @@ -8,7 +8,7 @@ in_array() { } _asp() { - local a= cur= prev= comps= + local verb='' i cur prev comps _get_comp_words_by_ref cur prev @@ -34,24 +34,34 @@ _asp() { return 0 fi - for word in "${COMP_WORDS[@]}"; do + # verb completion + for (( i = 0; i < ${#COMP_WORDS[@]}; ++i )); do + word=${COMP_WORDS[i]} if in_array "$word" ${verbs[ALL_PACKAGES]}; then - a=$word + verb=$word comps=$(\asp list-all | sed 's,.*/,,') break elif in_array "$word" ${verbs[LOCAL_PACKAGES]}; then - a=$word + verb=$word comps=$(\asp list-local | sed 's,.*/,,') break elif in_array "$word" ${verbs[NONE]}; then - a=$word + verb=$word break fi done - if [[ -z $a ]]; then - comps=${verbs[*]} - fi + # sub-verb completion + case $verb in + show) + if (( i < ${#COMP_WORDS[@]} - 2 )); then + comps=$(\asp ls-files "${COMP_WORDS[i+1]}") + fi + ;; + '') + comps=${verbs[*]} + ;; + esac if [[ $comps ]]; then COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) -- cgit v1.2.3-70-g09d2