Skip to content

Commit cf2f6e5

Browse files
author
Isaac Schaaf
committed
only complete the first arg to bake with a bake task, fallback on default completion after that
1 parent 8729d81 commit cf2f6e5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bake-completion.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
#!/usr/bin/env bash
22

33
_bake () {
4-
local cur
5-
_get_comp_words_by_ref -n : -c cur
6-
local tasks="$(bake | grep -v BAKEFILE | grep '^ ' | sed 's/^ //g' | cut -f1 -d' ')"
7-
COMPREPLY=( $(compgen -W "$tasks" -- $cur) )
4+
local cword cur tasks
5+
_get_comp_words_by_ref -n : -c cur cword
6+
tasks="$(bake | grep -v BAKEFILE | grep '^ ' | sed 's/^ //g' | cut -f1 -d' ')"
7+
if [[ "$cword" -eq "1" ]]; then
8+
mapfile -t COMPREPLY < <(compgen -W "$tasks" -- "$cur")
9+
else
10+
mapfile -t COMPREPLY < <(compgen -o default -- "$cur")
11+
fi
812

913
# NB: this is a workaround for bash's default of splitting words on colons
1014
# when bake tasks also use colons as a namespace separator. What we need to

0 commit comments

Comments
 (0)