Zsh Mailing List Archive
Messages sorted by:
Re: Completion question
- X-seq: zsh-users 5222
- From: Byron Foster <byron@xxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Completion question
- Date: Sat, 10 Aug 2002 20:29:41 -0700
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <3D53667B.8050202@xxxxxxxx> <15699.28431.791243.550522@xxxxxxxxxxxxxxxxxx>
Sven Wischnowsky wrote:
> Byron Foster wrote:
>> 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
Thanks, that works nicely for both rm and cp.
> 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).
I don't know enough, even though I'm learning, about the guts of the
completion functions to really follow what you are saying. However,
couldn't you just do what you did in the style definition, but do it in
the _rm function? that is select tags based on the contents of $words.
Doesn't the _arguments function do this for you? Again, I don't
know allot about these function, so I may be making no sense.
Messages sorted by: