-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccontrol
30 lines (27 loc) · 861 Bytes
/
ccontrol
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
#http://www.debian-administration.org/article/317/An_introduction_to_bash_completion_part_2
_ccontrol()
{
local cur prev opts instances
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="start stop force backup stat create update delete rename default view list qlist all qall nodename session version help"
instances=$(for x in `ccontrol qlist | awk -F ^ '{print $1}'`; do echo ${x} ; done)
case "${prev}" in
start|stop|restart|delete|session|stat)
COMPREPLY=( $(compgen -W "${instances}" -- ${cur}) )
return 0
;;
help)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
;;
esac
if [[ ${cur} == * ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _ccontrol ccontrol