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

Re: How to do a simple find-replace autocomplete?



On 2007-07-15 at 23:13 -0400, Mats Ahlgren wrote:
> How would one have the pattern "#dir" (perhaps defined via a regex) autocomplete using tab, invoking a script with the match (e.g. $ myAutoComp.py dir), which returns a newline-delimited list of possible completions to feed into the completion engine?
> This could be used in conjunction with a script which returns (from a hashmap) all directories N levels deep from your home directory -- saving lots of time if you're often looking for a uniquely-named subfolders.

> (sidenote: I'm more interested in the specific technique of interfacing with an outside script, rather than the end result.)

If you're using the standard ("new", a few years back) completion
system then all return values for any completion, in any context, are
returned by shell functions; there are many examples of completions
which come from calling a command and some of those use shell
associative arrays to cache the results.

Read through zshcompsys(1) for more information.

I guess doing something with _directories() is the way to go if you want
to change the concept of a directory for all tab-completion, but I'm not
very good with the completion system.

-Phil



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