Re: Is there a way to complete arguments with brace characters without using backslashes or quotes?
Trevor Avant <[email protected]>
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CADpHffGuP_+jokMsUVieCGqzC_ZdfiSOpGVwT+gqYzTcp+3G5Q@mail.gmail.com> |
Ok that setting gets me closer. However it doesn't get me all the way there
because if I add these other completions as follows:
#compdef myfun
compadd -Q a{b
compadd -Q a{c
compadd -Q a{cd
compadd -Q a{ce
Then
$ setopt ignore_braces
$ myfun <TAB>
completes to
$ myfun a{
and shows "a{b" and "a{c" but not "a{cd" and "a{ce". If I had "abb", "abc",
"abcd", and "abce", then it would show all of them.
On Mon, Mar 24, 2025 at 9:55 AM Mikael Magnusson <[email protected]> wrote:
> On Mon, Mar 24, 2025 at 7:09 AM Trevor Avant <[email protected]>
> wrote:
> >
> > Thanks, I have reduced my zsh configuration to a minimal setup, but I'm
> still getting the same results. Here is my /home/trevor/.zshrc
> >
> > fpath=(/home/trevor/zsh_completions/ $fpath)
> > autoload -Uz compinit promptinit
> > compinit
> > promptinit
> >
> > and here is /home/trevor/zsh_completions/_myfun
> >
> > #compdef myfun
> > compadd -Q a{b
> > compadd -Q a{c
> >
> > and then I enter
> >
> > $ setopt ignore_braces
> > $ myfun <TAB>
> >
> > which completes to
> >
> > $ myfun a{
> >
> > but then nothing happens on subsequent TAB presses (the two completion
> options aren't shown). If I change "a{b" and "a{c" to "abb" and "abc" then
> it works as expected (it shows the two options below prompt on the first
> TAB press, and then cycles through them on subsequent TAB presses). I am
> using Arch Linux and have tried a few different terminal emulators as well.
>
> I get the same result with that setup, it seems it worked for me
> because of this piece of configuration:
>
> zstyle ':completion:*' completer _complete _correct
>
> which is a little unexpected, at least to me. (my actual value for
> that key is _oldlist _expand _complete _correct fwiw, but the above is
> enough to reproduce the working result). My guess is the { gets parsed
> into some value other than a literal { at some point, and _correct
> cancels out this small discrepancy to show the wanted completions.
>
> --
> Mikael Magnusson
>