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

Re: Is there a way to complete arguments with brace characters without using backslashes or quotes?



Awesome, thank you! I've been trying to figure this out for so long, I'm ecstatic that I found a solution. I was trying a similar replacement with BUFFER in my zshrc but couldn't get it to work. I also couldn't figure out how to debug this, so thanks for the info about the _complete_debug option.

On Fri, Mar 28, 2025 at 5:24 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Mon, Mar 24, 2025 at 7:35 AM Trevor Avant <trevoravant@xxxxxxxxx> wrote:
>
> Ok that setting gets me closer. However it doesn't get me all the way there

A quick check with _complete_debug shows that regardless of compadd -Q
or the setting of ignorebraces the internals are assigning

_lastcomp[prefix]='a\{'

which won't match 'a{' on the command line when you arrive at the second TAB.

So what you need is something along the lines of

#compdef myfun
PREFIX=${PREFIX//\\\{/\{}
compadd -Q a{b
compadd -Q a{c
compadd -Q a{cd
compadd -Q a{ce

You might be able to use (Q) instead of the // replacement, but that
could unquote too much.


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