-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Yggdrasil.sh-completion.bash
37 lines (34 loc) · 1.39 KB
/
.Yggdrasil.sh-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
yggdrasil_completion() {
local current_word previous_word
current_word="${COMP_WORDS[COMP_CWORD]}"
previous_word="${COMP_WORDS[COMP_CWORD-1]}"
case "$previous_word" in
"build"|"start"|"stop"|"enter"|"manexec"|"extract"|"remove"|"stoprm"|"remove-image"|"list")
local options_file="./configuration/autocompletion/options.txt"
if [[ -f "$options_file" ]]; then
COMPREPLY=($(compgen -W "$(cat "$options_file")" -- "$current_word"))
else
COMPREPLY=()
fi
;;
"exec")
local options_file="./configuration/autocompletion/tools_options.txt"
if [[ -f "$options_file" ]]; then
COMPREPLY=($(compgen -W "$(cat "$options_file")" -- "$current_word"))
else
COMPREPLY=()
fi
;;
*)
case "$current_word" in
"build"|"start"|"stop"|"stoprm"|"list"|"enter"|"status"|"exec"|"manexec"|"record"|"extract"|"remove"|"remove-image"|"help"|"about")
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "build start stop stoprm list enter status exec manexec record extract remove remove-image help about" -- "$current_word"))
;;
esac
;;
esac
}
complete -F yggdrasil_completion Yggdrasil.sh