2011-11-01 22:14:45 +02:00
|
|
|
# service(8) and /etc/init.d/* completion -*- shell-script -*-
|
2010-06-09 22:19:05 +03:00
|
|
|
|
|
|
|
# This completes on a list of all available service scripts for the
|
|
|
|
# 'service' command and/or the SysV init.d directory, followed by
|
|
|
|
# that script's available commands
|
2011-04-05 00:35:51 +03:00
|
|
|
|
2010-06-09 22:19:05 +03:00
|
|
|
_service()
|
|
|
|
{
|
2011-04-21 11:04:51 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2010-06-09 22:19:05 +03:00
|
|
|
|
|
|
|
# don't complete past 2nd token
|
2011-04-21 11:04:51 +03:00
|
|
|
[ $cword -gt 2 ] && return 0
|
2010-06-09 22:19:05 +03:00
|
|
|
|
2011-07-26 23:11:13 +03:00
|
|
|
if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
|
2010-06-09 22:19:05 +03:00
|
|
|
_services
|
|
|
|
else
|
2011-04-21 11:04:51 +03:00
|
|
|
local sysvdir
|
2011-02-05 12:06:53 +02:00
|
|
|
[ -d /etc/rc.d/init.d ] && \
|
|
|
|
sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
|
2010-06-09 22:19:05 +03:00
|
|
|
COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
|
|
|
|
-ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
|
2011-06-18 23:26:57 +03:00
|
|
|
$sysvdir/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) )
|
2010-06-09 22:19:05 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
} &&
|
|
|
|
complete -F _service service
|
2011-04-12 23:45:02 +03:00
|
|
|
for svc in /etc/init.d/!($_backup_glob) /etc/rc.d/init.d/!($_backup_glob); do
|
2011-04-12 20:10:09 +03:00
|
|
|
[ -x "$svc" ] && complete -F _service $svc
|
2010-06-28 19:54:16 +03:00
|
|
|
done
|
|
|
|
unset svc
|
2010-06-09 22:19:05 +03:00
|
|
|
|
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|