summary refs log tree commit diff
path: root/pkgs/os-specific/linux/upstart/upstart-bash-completion
blob: f47d38c90ad2ebc6b650931b94c730c0835eb728 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
_upstart_comp_list(){
  COMPREPLY=()
  cur=${COMP_WORDS[COMP_CWORD]}
  if [ $COMP_CWORD -eq 1 ]; then
      COMPREPLY=( $(compgen -o filenames -W "$@" $cur) )
  fi
}

_upstart_complete() { _upstart_comp_list "$(initctl list 2>&1 | grep -E "$1" | cut -f2 -d ' ')"; }

_waiting(){ _upstart_complete "(waiting|instance)"; }
_running(){ _upstart_complete "(running|instance)"; }
_jobs(){ _upstart_comp_list "$(ls -1 /etc/event.d 2> /dev/null)"; }

complete -F _jobs status
complete -F _waiting start
complete -F _running stop
complete -F _running restart