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

PATCH: Re: completion function for apachectl



Fletch wrote:

> ...
> 
> [... Brutal savaging of my version choped :) ]

;-) sorry...

> ...
> 
>         I've been frustrated that TAB doesn't Do What I Mean for stuff 
> in /etc/rc.d/init.d several times.  You almost could generate it on
> the fly with a for over /etc/rc.d/init.d/*, maybe with a style for
> things that take strange arguments other than start or stop.

So here are some small functions... I didn't use a style yet, maybe
we'll be able to add some system specific magic so that users don't
have to be bothered...

That change in _normal makes it use ${PWD}/$words[1] when completing
arguments for something that is given as a relative path (`./foo <TAB>').


Bye
 Sven

Index: Completion/Base/_sub_commands
===================================================================
RCS file: _sub_commands
diff -N _sub_commands
--- /dev/null	Mon Dec 11 17:26:27 2000
+++ _sub_commands	Mon Feb 26 07:00:21 2001
@@ -0,0 +1,9 @@
+#autoload
+
+local expl
+
+if [[ CURRENT -eq 2 ]]; then
+  _wanted commands expl command compadd "$@"
+else
+  _message 'no more arguments'
+fi
Index: Completion/Core/_normal
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_normal,v
retrieving revision 1.5
diff -u -r1.5 _normal
--- Completion/Core/_normal	2001/01/15 09:11:32	1.5
+++ Completion/Core/_normal	2001/02/26 15:00:21
@@ -30,6 +30,10 @@
     eval cmd1\=$command
     cmd2="$command[2,-1]"
     curcontext="${curcontext%:*:*}:${cmd2}:"
+  elif [[ "$command" = ..#/* ]]; then
+    cmd1="${PWD}/$command"
+    cmd2="${command:t}"
+    curcontext="${curcontext%:*:*}:${cmd2}:"
   elif [[ "$command" = */* ]]; then
     cmd1="$command"
     cmd2="${command:t}"
Index: Completion/User/_apachectl
===================================================================
RCS file: _apachectl
diff -N _apachectl
--- /dev/null	Mon Dec 11 17:26:27 2000
+++ _apachectl	Mon Feb 26 07:00:21 2001
@@ -0,0 +1,3 @@
+#compdef apachectl
+
+_sub_commands start startssl stop restart fullstatus status graceful configtest help
Index: Completion/User/_init_d
===================================================================
RCS file: _init_d
diff -N _init_d
--- /dev/null	Mon Dec 11 17:26:27 2000
+++ _init_d	Mon Feb 26 07:00:21 2001
@@ -0,0 +1,5 @@
+#compdef -P */(init|rc[0-9]#).d/*
+
+# This should probably be system specific...
+
+_sub_commands start stop

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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