-
Notifications
You must be signed in to change notification settings - Fork 13
/
autocomplete.me
40 lines (32 loc) · 1.35 KB
/
autocomplete.me
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
#!/bin/bash
ROOT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
export PATH=$ROOT_DIR${PATH:+:${PATH}}
_exec_bash(){
local cur prev words cword package
cur=${COMP_WORDS[COMP_CWORD]}
if [ "${COMP_WORDS[1]}" = "storedrelease" ]; then
# nothing comes after release
if [ "${#COMP_WORDS[@]}" -gt "4" ]; then
return
fi
if [ "${#COMP_WORDS[@]}" -gt "3" ]; then
COMPREPLY=($(compgen -W "$(ls startscripts | xargs) /bin/bash" -- "$cur"))
return
fi
# omit the first line
STORED_RELEASES=$(tail -n +2 .stored_images.txt | grep = | cut -d '=' -f 1)
COMPREPLY=($(compgen -W "${STORED_RELEASES}" -- "$cur"))
return
fi
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
COMPREPLY=($(compgen -W "$(ls startscripts | xargs) /bin/bash /opt/write_osdeps.bash" -- "$cur"))
return
fi
COMPREPLY=($(compgen -W "base devel release CD storedrelease $(ls startscripts | xargs) /bin/bash write_osdeps" -- "$cur"))
}
complete -F _exec_bash ./exec.bash
complete -F _exec_bash exec.bash
complete -W "base devel release CD storedrelease" ./stop.bash
complete -W "base devel release CD storedrelease" stop.bash
complete -W "base devel release CD storedrelease" ./delete_container.bash
complete -W "base devel release CD storedrelease" delete_container.bash