From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7505 invoked from network); 9 Aug 2002 07:27:03 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 9 Aug 2002 07:27:03 -0000 Received: (qmail 18432 invoked by alias); 9 Aug 2002 07:26:44 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5214 Received: (qmail 18418 invoked from network); 9 Aug 2002 07:26:43 -0000 From: Sven Wischnowsky MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15699.28431.791243.550522@wischnow.berkom.de> Date: Fri, 9 Aug 2002 09:28:15 +0200 To: zsh-users@sunsite.dk Subject: Re: Completion question In-Reply-To: <3D53667B.8050202@base2.cc> References: <3D53667B.8050202@base2.cc> X-Mailer: VM 7.03 under 21.5 (patch 5) "beets" XEmacs Lucid Byron Foster wrote: > > Hello, > > I can't figure out how to configure the completion system so that > only directories are listed after typing 'rm -r ' at the command line, > but without the the '-r' option only list files. Can I do this by only > using styles, or do I need to write an _rm function? Im using zsh 4.0.4 > > so far for only listing files I have > > zstyle ':completion:*:complete:rm:*' file-patterns '*(^-/):files' > > Of course this breaks 'rm -r' You can always use the `-e' option and then have a look at the $words array, which is one of the special parameters set by the completion code. It contains the word on the line. So: zstyle -e ':completion:*:complete:rm:*' file-patterns ' if (( $words[(I)-r] )); then reply=("*(-/):directories") else reply=("*(^-/):files") fi' This doesn't catch the case where the `-r' option is put together with other options in the same string (like `-ir'). Even if there were a function for `rm' which would do option parsing, there currently were no way of smuggling code into it to take advantage of the information about options on the line gathered there. Except for that `-e' thing above (if a `_rm' function would use _arguments we should have $opt_args available inside that code). Bye Sven -- Sven Wischnowsky wischnow@berkom.de