Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _complete: insert unambiguous when globbing
- X-seq: zsh-users 27449
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Tomasz Pala <gotar@xxxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: _complete: insert unambiguous when globbing
- Date: Mon, 3 Jan 2022 16:25:18 -0800
- Archived-at: <https://zsh.org/users/27449>
- In-reply-to: <20220103123903.GA20434@polanet.pl>
- List-id: <zsh-users.zsh.org>
- References: <20220103123903.GA20434@polanet.pl>
On Mon, Jan 3, 2022 at 7:24 AM Tomasz Pala <gotar@xxxxxxxxxx> wrote:
>
> ls 2[tab] ==> 20 this is expected
> ls 2*[tab] !=> 20 how to make this to be expanded first to
>
> "20", and then the regular rules to proceed (either menu complete I
> always use, or _expand)?
The basic problem here is that the set of common prefixes always
includes the string originally on the command line when deciding
whether to insert a partial result, and except in pretty unusual cases
none of the results is going to include the "*" character, so the best
you're going to get is to always immediately enter menu completion.
You can get that with
setopt globcomplete
This varies a bit depending on your key bindings and completer style.
The above is required when you have TAB bound to expand-or-complete,
but for example with
bindkey ^I complete-word
zstyle ':completion:*' completer _complete _expand
you can get a similar set of results, but menu completion is entered
with all possible expansions instead of all matching files.
> One more note - zsh knows where the first ambiguous character is, even
> with globbing, as it's shown with show-ambiguity style.
Hmm. When I try this with your 20{a,b,c,d}.x example, globcomplete
gives "20" as the unambiguous prefix but my second formulation has
only "2". This appears to be because with globcomplete on, the set of
glob matches has already been calculated before entering the
completion process; the prefix from the command line is determined
very early in both cases. This suggests that some fiddling with the
value of compstate[insert] could produce the "show prefix on first
tab, enter menu on second tab" effect that I think you're asking for,
at least some of the time, but I'm not sure where to do that.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author