zsh-users
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@berkom.de>
To: zsh-users@sunsite.dk
Subject: Re: Completion question
Date: Fri, 9 Aug 2002 09:28:15 +0200	[thread overview]
Message-ID: <15699.28431.791243.550522@wischnow.berkom.de> (raw)
In-Reply-To: <3D53667B.8050202@base2.cc>


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


  reply	other threads:[~2002-08-09  7:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-09  6:51 Byron Foster
2002-08-09  7:28 ` Sven Wischnowsky [this message]
2002-08-11  3:29   ` Byron Foster
     [not found] <20110602191951.566gmx1@mp009.gmx.net>
2011-06-06 22:33 ` meino.cramer
2011-06-07  5:12   ` Jun T.
2011-06-07  8:29   ` Peter Stephenson
2011-06-07  8:53   ` Jérémie Roquet
  -- strict thread matches above, loose matches on Subject: below --
2004-08-31 11:02 Completion Question Sean Johnston
2004-08-31 11:51 ` Oliver Kiddle
2003-02-06  1:32 completion question Le Wang
2003-02-10 11:06 ` Oliver Kiddle
2002-06-11 11:40 Completion question jarausch
2002-06-11 11:55 ` Sven Wischnowsky
2001-07-30  2:15 completion question Eric D. Friedman
2001-07-30  2:32 ` Bart Schaefer
     [not found] <20010704142951.B4036@dlux.hu>
2001-07-04 12:50 ` Andrej Borsenkow
2001-07-04 13:02   ` Nadav Har'El
2001-07-04 13:27     ` Andrej Borsenkow
2001-07-04 14:45     ` dLux
2001-07-04 15:43       ` Sven Wischnowsky
2001-07-04 15:47         ` Sven Wischnowsky
2001-07-04 10:57 dLux
2001-07-04 11:10 ` Andrej Borsenkow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15699.28431.791243.550522@wischnow.berkom.de \
    --to=wischnow@berkom.de \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).