From 395803ff628e41940bbaaf5f1ffbcf591b007102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9moulins?= Date: Wed, 18 May 2011 22:16:02 +0200 Subject: Add a zsh completion script for the command rc.d. seblu: Fix typo, add vim modeline Signed-off-by: Sebastien Luttringer --- Makefile | 3 ++- zsh-completion | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 zsh-completion diff --git a/Makefile b/Makefile index 25c9b58..968cfb9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ VER := $(shell git describe) -DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d /etc/bash_completion.d +DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d /etc/bash_completion.d /usr/share/zsh/site-functions minilogd: minilogd.o @@ -15,6 +15,7 @@ install: minilogd installdirs install -m755 -t $(DESTDIR)/sbin minilogd rc.d modprobe-blacklist ln -s /run/initscripts/modprobe-blacklist.conf $(DESTDIR)/etc/modprobe.d/arch-blacklist.conf install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d + install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d clean: rm -f minilogd minilogd.o diff --git a/zsh-completion b/zsh-completion new file mode 100644 index 0000000..bf8d9d0 --- /dev/null +++ b/zsh-completion @@ -0,0 +1,34 @@ +#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) + _arguments "*: :" + ;; + help) + _arguments "*: :" + ;; + *) + _arguments "*: :_services" + ;; + esac + ;; + esac +} + +_rc.d "$@" + +# vim: set ts=2 sw=2 ft=sh noet: -- cgit v1.2.3