Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: _a2utils



> I've made a new completion for debian specific apache utils :
> 
>  + _a2utils gives completion for a2ensite, a2dissite, a2enmod, a2dismod commands.

> #compdef a2ensite a2dissite a2enmod a2dismod
> 
> case "$service" in
>     a2ensite)
> 	sites=( /etc/apache2/sites-available/*(:t) )
> 	_wanted sites expl sites compadd $sites
> 	;;
>     a2dissite)
> 	sites=( /etc/apache2/sites-enabled/*(:t) )
> 	_wanted sites expl sites compadd $sites
> 	;;
>     a2enmod)
> 	mods=( /etc/apache2/mods-available/*.load(:r:t) )
> 	_wanted mods expl mods compadd $mods
> 	;;
>     a2dismod)
> 	mods=( /etc/apache2/mods-enabled/*.load(:r:t) )
> 	_wanted mods expl mods compadd $mods
> 	;;
> esac
> 
> return 0

Tweaking a bit..

Index: Completion/Debian/Command/_a2utils
===================================================================
RCS file: Completion/Debian/Command/_a2utils
diff -N Completion/Debian/Command/_a2utils
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Debian/Command/_a2utils	14 Oct 2006 18:05:37 -0000
@@ -0,0 +1,24 @@
+#compdef a2ensite a2dissite a2enmod a2dismod
+
+local -a mods
+
+case "$service" in
+    a2ensite)
+	_wanted sites expl sites \
+	  _files -W /etc/apache2/sites-available
+	;;
+    a2dissite)
+	_wanted sites expl sites \
+	  _files -W /etc/apache2/sites-enabled
+	;;
+    a2enmod)
+	mods=( /etc/apache2/mods-available/*.load(N:r:t) )
+	_wanted mods expl mods compadd -a mods
+	;;
+    a2dismod)
+	mods=( /etc/apache2/mods-enabled/*.load(N:r:t) )
+	_wanted mods expl mods compadd -a mods
+	;;
+esac
+
+return 0



Messages sorted by: Reverse Date, Date, Thread, Author