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

Re: String partial match from both left and right.



On Fri, 31 Aug 2018 15:54:02 +0530
Abhijeet Rastogi <abhijeet.1989@xxxxxxxxx> wrote:
> Hi everyone,
> 
> I have this super simple zsh completion function.
> 
> function hello() {
>     arg=${@[1]}
>     echo $arg
> }
> function _hello {
>     _values -s ' ' 'dashboards' foo bar foo-bar
> }
> compdef _hello hello
> 
> And what I want is, if I do:-
> 
> $hello bar<TAB>
> 
> I want `foo-bar` to come in the completion menu. I figured that it has
> something to do with mater-list but I can't seem to get it working.
> 
> zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'l:|=*
> r:|=*'

(This should really got to zsh-users as it's not about implementation.)

Best I could come up with quickly was

zstyle ':completion:*:hello:*' matcher-list 'r:|-*'

where it works if you type "-b", i.e. you need the hyphen but not
anything before it.

pws



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