aboutsummaryrefslogtreecommitdiff
path: root/zsh-completion
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2011-05-23 01:31:48 +0200
committerTom Gundersen <teg@jklm.no>2011-05-23 01:31:48 +0200
commitdfdf8b683633d89a9c7c7560397c57a8a1594147 (patch)
treedca5033418b54a29dd3722cb2a119e852bd700ad /zsh-completion
parenta3314c769768d8c40b46767d26f9783d4f359358 (diff)
parent18adeacb36967463330060237725ffbdfd47e2a7 (diff)
downloadinitscripts-dfdf8b683633d89a9c7c7560397c57a8a1594147.tar.xz
Merge remote-tracking branch 'seblu/master'
Diffstat (limited to 'zsh-completion')
-rw-r--r--zsh-completion37
1 files changed, 37 insertions, 0 deletions
diff --git a/zsh-completion b/zsh-completion
new file mode 100644
index 0000000..f1b7165
--- /dev/null
+++ b/zsh-completion
@@ -0,0 +1,37 @@
+#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
+ list|help)
+ _arguments "*: :"
+ ;;
+ 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: