Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: String partial match from both left and right.
- X-seq: zsh-workers 43362
- From: Abhijeet Rastogi <abhijeet.1989@xxxxxxxxx>
- To: okiddle@xxxxxxxxxxx
- Subject: Re: String partial match from both left and right.
- Date: Sun, 2 Sep 2018 10:07:32 +0530
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0nXQikJUn2GUc5tj1jGU7pIA9OKOYhH6TcYUJ+ums88=; b=MTkcr8vpOYgU4rNpeEbognBl2wzzb6qR98pRmaxFOgDcrYyzM0CagQNsXuge07L2b6 A3S7HS/C6Fc1cO0gIO39yHZ4fXQkGproirx2mlTanC5EjESZ/PY+fTiflwwO6VToxU6T skfsDZwbHFEH3MGV+VIoRoFHB/iCaSl7YHOL4GaVqzwQL2PRVkS3hd0RZW18b7n04oXw C+wvI3LHTyCBn3S3Joz5ZJjn47CLALvbsyX+DywqOywR2N23NAOjvFOiQYBu/mf8HxQl 4W1HxrZ7EPphYF3jWAKOF//qEwpRlLZHhEjVRFzCAbBm7nTcbPuoxWShNjqjsOEu2glG 9HrA==
- In-reply-to: <23890-1535713868.126845@ueVC.nT4d.iPhW>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CACXxYfxO8Ws4+Tf-NqSZW9b7gP7opRiEY5Dtpm7ZABG1K0N6Lg@mail.gmail.com> <23890-1535713868.126845@ueVC.nT4d.iPhW>
Hi,
Thanks, Peter.
And special thanks to Oliver for the excellent explanation so I could up on
what you gave me. I ended up using your approach.
On Fri, Aug 31, 2018 at 4:41 PM Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
> Abhijeet Rastogi wrote:
> > 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.
>
> You're right that the matching control is the way to achieve this and in
> particular the 'l:|=*' specification.
>
> > zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'l:|=* r:|=*'
>
> That sets a global matcher to apply for all completions. It will first
> try case-insensitive matching and then try again with extra characters
> allowed at both the beginning (left) and end (right) of what has been
> typed. When you complete bar<tab>, the "bar" candidate will match when
> doing the initial case-insensitive match and is accepted. It then never
> gets to try the second matching rule.
>
> You need the l: spec in the first argument so it would work with either:
> zstyle ':completion:*' matcher-list 'l:|=*'
> or:
> zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
>
> That assumes you don't have any other matcher-list styles with a more
> specific context.
>
> Also, as I mentioned setting matcher-list is a fairly global setting. If
> you only want this for hello then the matcher style might be more
> appropriate:
> zstyle ':completion:*:hello:values:*' matcher 'l:|=*'
>
> Alternatively you might want to specify the matcher directly in the
> _hello function. For example:
>
> function _hello {
> _wanted dashboards expl 'dashboard' compadd -M 'l:|=*' foo bar foo-bar
> }
>
> There are other things you might try, for example r:|-=* allows f-b to
> match foo-bar.
>
> Oliver
>
--
Cheers,
Abhijeet Rastogi (shadyabhi)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author