aboutsummaryrefslogtreecommitdiff
path: root/zsh-completion
blob: e5c2850ad0dee6e00a32d5ab0b737b87b61ca75e (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
28
29
30
31
32
33
34
35
36
37
38
39
40
#compdef rc.d

_rc.d () {
	local curcontext="$curcontext" state line
	typeset -A opt_args

	 _arguments "1: :->action" "*: :->service"

	case $state in
		action)
			_arguments "1:action:(list help start stop restart)"
			;;
		service)
			local action="$words[2]"
			curcontext="${curcontext%:*:*}:rc.d-${action}:"

			case $action in
				help)
					_arguments "*: :"
					;;
				list)
					_arguments "2: :(started stopped)"
					;;
				start)
					_arguments "*: :($(comm -23 <(echo /etc/rc.d/*(N-*:t)|tr ' ' '\n') <(echo /run/daemons/*(N:t)|tr ' ' '\n')))"
					;;
				stop|restart|reload)
					_arguments "*: :(/run/daemons/*(N:t))"
					;;
				*)
					_arguments "*: :(/etc/rc.d/*(N-*:t))"
					;;
			esac
		;;
  esac
}

_rc.d "$@"

# vim: set ts=2 sw=2 ft=sh noet: