blob: f44c0b75e0841da9334b49ed108fe89964eb3072 (
plain)
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
|
#compdef Start Restart Stop Reload
## vim:ft=zsh
## Completion for the Start, Stop etc. functions introduced in ../function
##
## Note: This script parses the files in /etc/init.d to generate the matches.
## If you'd prefer to just have all the files in /etc/init.d as arguments,
## write "zstyle ':completion:*:*:_initd' all-files true" into your zshrc
##
## Most of this has been taken from the _init_d function provided with 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
if zstyle -t ':completion:*:*:_initd' all-files; then
_arguments -s '*:init script:_path_files -W /etc/init.d -g "*(*)"'
return 0
fi
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}
|