-
-
Notifications
You must be signed in to change notification settings - Fork 361
/
Copy pathexercism_completion.bash
51 lines (45 loc) · 1.18 KB
/
exercism_completion.bash
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
_exercism () {
local cur prev
COMPREPLY=() # Array variable storing the possible completions.
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
opts="--verbose --timeout"
commands="configure download open
submit test troubleshoot upgrade version workspace help"
config_opts="--show"
version_opts="--latest"
if [ "${#COMP_WORDS[@]}" -eq 2 ]; then
case "${cur}" in
-*)
COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) )
return 0
;;
*)
COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) )
return 0
;;
esac
fi
if [ "${#COMP_WORDS[@]}" -eq 3 ]; then
case "${prev}" in
configure)
COMPREPLY=( $( compgen -W "${config_opts}" -- "${cur}" ) )
return 0
;;
version)
COMPREPLY=( $( compgen -W "${version_opts}" -- "${cur}" ) )
return 0
;;
help)
COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) )
return 0
;;
*)
return 0
;;
esac
fi
return 0
}
complete -o bashdefault -o default -o nospace -F _exercism exercism 2>/dev/null \
|| complete -o default -o nospace -F _exercism exercism