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 43356
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Abhijeet Rastogi <abhijeet.1989@xxxxxxxxx>
- Subject: Re: String partial match from both left and right.
- Date: Fri, 31 Aug 2018 13:11:08 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1535713870; bh=Dn7VUtUD4sefbObNmVQ8kfVfLDy7z2jL62KbFBeSUM4=; h=From:References:To:Subject:Date:From:Subject; b=i6S5z4EFR6piJLjC0ElNWdBx8p0UY1/30QcOOdDJdfP2U9Oq6Jj3h3sdgtNFIvsT5McVICAVHNhLTG1oxSjmvw7odo7EimWgE9T/bZ6XuS+9skKx51HOMkZSoUIWM6hCyxYWWrAQUNSEgfNadfNxxGtxTEvzLQK63YF3wMPu71NzjyDVeIrf6zdqEf1dtERlmNL+RAbD4I0hXEtJg1fLJUZY1IKgSjZ9cfhOy3Pc/HHD7wnQ0eiitkrFC4gqfjAZNQBFC3+kKVv81mBM5K/SiN+iBWB7ozVAt3Qrk0Qz61SDkBc0hFizclxCBj5YscPc4nwtc0m7/w+kqV2nWUmpnA==
- In-reply-to: <CACXxYfxO8Ws4+Tf-NqSZW9b7gP7opRiEY5Dtpm7ZABG1K0N6Lg@mail.gmail.com>
- 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>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author