-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmill-completion.bash.inc
55 lines (41 loc) · 1.26 KB
/
mill-completion.bash.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# bash completion for mill
# https://github.com/lefou/mill-bash-completion/blob/master/mill.complete.sh
_mill()
{
# variables
local cur prev split=false
local mill_out dot_count mill_resolve
COMPREPLY=()
_get_comp_words_by_ref -n : cur prev
_comp__split_longopt && split=true
case $prev in
-h|--home|-p|--predef)
_filedir
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c -h -p -s -w -i\
--code --color\
--disable-ticker\
--help --home\
--interactive\
--no-default-predef\
--predef\
--silent
--watch' -- "$cur" ) )
else
if [[ "$cur" =~ .*[.].* ]]; then
# already specified a dot, so complete all
mill_out="$( mill --disable-ticker resolve __._ 2> /dev/null )"
COMPREPLY=( $( compgen -W "${mill_out}" -- "$cur" ) )
else
# nothing specified yet
mill_out="$( mill --disable-ticker resolve _ _._ 2> /dev/null )"
COMPREPLY=( $( compgen -W "${mill_out}" -- "$cur" ) )
fi
fi
__ltrim_colon_completions "${cur}"
} &&
complete -F _mill mill && complete -F _mill m