summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2017-03-11 21:16:32 -0500
committerDave Reisner <dreisner@archlinux.org>2017-03-12 09:45:41 -0400
commit82951aafc58d0ea4529387bd180d28a664506743 (patch)
tree6c2a289ead565689b39584bd6a3218ee0d5a7554 /shell
parent291ebc3c5ff22c62b035a457b750de226724ceac (diff)
downloadasp32-82951aafc58d0ea4529387bd180d28a664506743.tar.xz
add ls-files subcommand, allow showing files other than PKGBUILD
Diffstat (limited to 'shell')
-rw-r--r--shell/bash-completion26
1 files changed, 18 insertions, 8 deletions
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") )