-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash-completion
More file actions
24 lines (22 loc) · 813 Bytes
/
bash-completion
File metadata and controls
24 lines (22 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# rc.d bash completion by Seblu <seblu@seblu.net>
_rc_d()
{
local action cur prev
actions='help list start stop reload restart'
options='-s --started -S --stopped -a --auto -A --noauto'
_get_comp_words_by_ref cur prev
_get_first_arg
if [[ -z "$arg" ]]; then
COMPREPLY=($(compgen -W "${actions} ${options}" -- "$cur"))
elif [[ "$arg" == help ]]; then
COMPREPLY=()
elif [[ "$arg" == start ]]; then
COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort)))
elif [[ "$arg" =~ stop|restart|reload ]]; then
COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort))
else
COMPREPLY=($(compgen -W "${options} $(cd /etc/rc.d && compgen -f -X 'functions*')" -- "$cur"))
fi
}
complete -F _rc_d rc.d
# vim: set ts=2 sw=2 ft=sh noet: