forked from nim-lang/nimble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nimble.bash-completion
46 lines (41 loc) · 1.32 KB
/
nimble.bash-completion
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
# vim: filetype=sh
_nimble()
{
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=()
if declare -F _init_completions >/dev/null 2>&1; then
_init_completion || return
fi
case "$prev" in
init|update|refresh|publish|search|build)
# no needed or available completion
;;
c|cc|js)
_filedir '@(nim)'
;;
install)
COMPREPLY=( $( nimble list 2> /dev/null | grep "^$cur" | grep -v '^ ' | tr -d ':') )
;;
path)
COMPREPLY=( $( nimble list -i 2> /dev/null | cut -d' ' -f1 | grep "^$cur" ) )
;;
uninstall)
COMPREPLY=( $( nimble list -i 2> /dev/null | awk -F'( |\\[|\\])' '{ f=4; while($f) { l=length($f); if(substr($f, l, l)==",") { $f=substr($f, 0, l-1) }; print $1 "@" $f; f++; }}' | sort -f | grep "^$cur" ) )
;;
list)
COMPREPLY=( $( compgen -W '--ver -i --installed' -- $cur ) )
;;
*)
# no $prev: suggest commands or flags
if [[ "$cur" == -* ]]; then
kw="-h -v -y -n --reject --version --accept --ver --help"
else
kw="install init publish uninstall build c cc js refresh search list path"
fi
COMPREPLY=( $( compgen -W "${kw}" -- $cur ) )
;;
esac;
return 0
}
complete -F _nimble nimble