blob: e1c81b2010fbfb22d5db073e22c35b6e4acacd7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#compdef Start Restart Stop Reload
## vim:ft=zsh
typeset arguments file bang
typeset specific=${service:l}
typeset action='(st(art|op|atus)|(force-|)re(start|load)|debug_(up|down)|dump(|_stats)|add|delete|clean|list)'
typeset -a scripts
# Most of the loop's content has been taken from the _init_d
# completion function provided with zsh
for file in /etc/init.d/*(*); {
read -u0 -k2 bang < $file && [[ $bang == '#!' ]] &&
[[ -n ${${(j:|:s:|:)${(M)${(f)"$(< $file)"}:#[[:blank:]]#(\'|)(${~action}[[:blank:]]#\|[[:blank:]]#)#${~specific}([[:blank:]]#\|[[:blank:]]#${~action})#(\'|)\)}}//[^-a-z_]} ]] &&
scripts+=${file##*/}
}
_wanted script expl script compadd $scripts
|