2011-06-18 04:44:09 +00:00
|
|
|
# rc.d bash completion by Seblu <seblu@seblu.net>
|
|
|
|
|
2011-08-08 04:11:13 +00:00
|
|
|
_rc_d()
|
2011-06-18 04:44:09 +00:00
|
|
|
{
|
2011-08-08 04:11:13 +00:00
|
|
|
local action cur prev
|
|
|
|
action="help list start stop reload restart"
|
|
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
if ((COMP_CWORD == 1)); then
|
2011-06-18 04:44:09 +00:00
|
|
|
COMPREPLY=($(compgen -W "${action}" -- "$cur"))
|
2011-08-08 04:11:13 +00:00
|
|
|
elif [[ "$prev" == help ]]; then
|
2011-06-18 04:44:09 +00:00
|
|
|
COMPREPLY=()
|
2011-08-08 04:11:13 +00:00
|
|
|
elif [[ "$prev" == list ]]; then
|
|
|
|
((COMP_CWORD == 2)) && COMPREPLY=($(compgen -W "started stopped" -- "$cur")) || COMPREPLY=()
|
|
|
|
elif [[ "$prev" == start ]]; then
|
2011-06-18 04:44:09 +00:00
|
|
|
COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort)))
|
2011-08-08 04:11:13 +00:00
|
|
|
elif [[ "$prev" =~ stop|restart|reload ]]; then
|
2011-06-18 04:44:09 +00:00
|
|
|
COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort))
|
2011-08-08 04:11:13 +00:00
|
|
|
elif ((COMP_CWORD > 1)); then
|
2011-06-18 04:44:09 +00:00
|
|
|
COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort))
|
|
|
|
fi
|
|
|
|
}
|
2011-08-08 04:11:13 +00:00
|
|
|
complete -F _rc_d rc.d
|
2011-06-18 04:44:09 +00:00
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 ft=sh noet:
|