[arch-projects] [initscripts] rc.d zsh completion

Tom Gundersen teg at jklm.no
Wed May 18 16:45:07 EDT 2011


Hi,

Clément submitted the attached zsh completion file for review.

(Anyone should be able to post to the mailinglist, don't know what the
problem might have been).

Cheers,

Tom

---------- Forwarded message ----------
From: Clément Démoulins <clement at archivel.fr>
Date: 2011/5/18
Subject: Re: [arch-general] rc.d bash completion
To:
Cc: General Discussion about Arch Linux <arch-general at archlinux.org>


Le 18/05/2011 22:31, Tom Gundersen a écrit :
> 2011/5/18 Clément Démoulins <clement at archivel.fr>:
>> Le 18/05/2011 18:24, Grigorios Bouzakis a écrit :
>>> Auguste Pop wrote:
>>>> i wrote a very simple rc.d bash completion script. is there any chance
>>>> it can be used upstream?
>>>
>>> I noticed earlier theres one for zsh in the AUR as well. I was about to
>>> suggest to the author to send it upstream but negelcted to.
>>> https://aur.archlinux.org/packages.php?ID=49136
>>>
>>> Greg
>>>
>> Hello,
>> I'm the author of the complection script for zsh and ok i can make a git
>> patch.
>
> Thanks! I'll route all this through Seblu (just write to
> arch-projects at archlinux.org) as he is the one working on rc.d (and he
> has some outstanding patches, so better let him coordinate it).
>
> Cheers,
>
> Tom

I tried to send the patch to arch-projects at archlinux.org but i'm not
allowed to post in this mailing list.
I join the patch if you can send it.

Clément

--
Clef GPG : 0xDD51E028
-------------- next part --------------
From 90f7a583e4bc4219fcceec60cf5e610b40a633a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9moulins?= <clement at archivel.fr>
Date: Wed, 18 May 2011 22:16:02 +0200
Subject: [PATCH] Add a zsh completion script for the command rc.d.

---
 Makefile |    3 ++-
 _rc.d    |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletions(-)
 create mode 100644 _rc.d

diff --git a/Makefile b/Makefile
index 6923840..36668d3 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
+DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /usr/share/zsh/site-functions
 
 minilogd: minilogd.o
 
@@ -13,6 +13,7 @@ install: minilogd installdirs
 	install -m755 -t $(DESTDIR)/etc/cron.hourly adjtime
 	install -m755 -t $(DESTDIR)/etc/rc.d functions hwclock network netfs
 	install -m755 -t $(DESTDIR)/sbin minilogd rc.d
+	install -m644 -t $(DESTDIR)/usr/share/zsh/site-functions _rc.d
 
 clean:
 	rm -f minilogd minilogd.o
diff --git a/_rc.d b/_rc.d
new file mode 100644
index 0000000..b222bb6
--- /dev/null
+++ b/_rc.d
@@ -0,0 +1,36 @@
+#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: filetype=zsh
-- 
1.7.5.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: not available
URL: <http://mailman.archlinux.org/pipermail/arch-projects/attachments/20110518/9586dd8f/attachment.asc>


More information about the arch-projects mailing list