1_upstart_comp_list(){
2 COMPREPLY=()
3 cur=${COMP_WORDS[COMP_CWORD]}
4 if [ $COMP_CWORD -eq 1 ]; then
5 COMPREPLY=( $(compgen -o filenames -W "$@" $cur) )
6 fi
7}
8
9_upstart_complete() { _upstart_comp_list "$(initctl list 2>&1 | grep -E "$1" | cut -f2 -d ' ')"; }
10
11_waiting(){ _upstart_complete "(waiting|instance)"; }
12_running(){ _upstart_complete "(running|instance)"; }
13_jobs(){ _upstart_comp_list "$(ls -1 /etc/event.d 2> /dev/null)"; }
14
15complete -F _jobs status
16complete -F _waiting start
17complete -F _running stop
18complete -F _running restart