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

Fake parameter completion?



zsh-users—

I wanted to use autocompletion to complete various “debugging” environment variables, and I came up with something that works, but I don’t understand why it works and some other attempts don’t.  First, the task: sh derivatives let you specify extra environment variables for a command by writing them before the command, something like this:

	% UseExtraSpiffyLogging=1 ./mytool

The point is that they are ordinarily undefined, so normal parameter completion won’t match them, but I want them completed anyway.  Sounds like a job for the “fake” style, which I’ve successfully used in the past; that plus _complete_help led me to this:

	zstyle ':completion:complete:-command-::parameters' fake UseExtraSpiffyLogging

This sort of works, but completes “UseEx<tab>” to “UseExtraSpiffyLogging<space>” when really I want no space, or ideally a magic “=“.  Re-reading the documentation, I found the “fake-parameters” style.  My first attempt didn’t complete anything at all:

	zstyle ':completion:complete:-command-::parameters' fake-parameters UseExtraSpiffyLogging

…so I relaxed the context a bit, and now I get the completion *with* the magic “=“, which is perfect:

	zstyle ':completion:complete:-command-::*' fake-parameters UseExtraSpiffyLogging

…except that now I have questions:

1. Why are “fake” and “fake-parameters” distinct styles?  Obviously they behave differently in practice, but why couldn’t “fake” take the position into account and add the magic “=“ like “fake-parameters” does?  (The answer probably has to do with the *other* additional feature that “fake-parameters” provides, which is type-sensitivity, though it seems like “fake” could still do the magic “=“.)

2. What is the actual value of the “*” in the context?  Not “parameters”, apparently.  (I should mention that I do not truly understand zshcompsys.)

Thanks,


—Chris N.


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