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

Re: psychiatric help



On Sun, Apr 5, 2026 at 9:01 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> That's where I want to be but I have no idea how to get into the
> widget.  Never been near a widget yet.

If you've got "compinit" in your .zshrc, you've been near hundreds of
widgets.  "Widget" is just the zsh name for a function that is
executed by ZLE.

> On 2026-04-05 19:24, Bart Schaefer wrote:
> >
> > The place you can access $BUFFER is in the zle-line-finish widget.

zle-line-finish is a "special" widget that ZLE runs automatically just
after accept-line (the widget normally bound to Enter/Return).  By
default it's not defined at all, so you have to create it.
> > zle -N zle-line-finish _tt
Like that.

> > then put that nauseating thing back into BUFFER, as long as you're
> > still in the zle-line-finish widget.

"In" the widget just means still running the commands of the shell function.

> > Try that and observe the result.
> Ok, I can copy that and give it a go.  Probably still want _execute cuz
> it does some other stuff too

The important bit is that you should NOT call "eval" of anything, and
that the assignment to BUFFER contains the command line you want to
run.  So if you want to keep using _execute, you would likely replace
the "eval" by the assignment of BUFFER=.

> How do we access the users archives?

https://www.zsh.org/mla/ although I believe searching is still broken
so you need to know an article number or pore over the indexes.

> Any chance of doing this kind of thing in preexec()?
> So it's always available?

zle-line-finish runs before preexec and is also always available.
However, you can't do in preexec what your ,H thing does, for two
reasons:  First, preexec can't change what is going to be executed, it
can only examine it.  Second, preexec is called after aliasing,
globbing, etc., happens, so you can't get at the partly-rewritten
command line that you want.




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