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

Re: prevent some lines directly coming from the history from being executed



On 2022-05-25 18:25:40 -0700, Bart Schaefer wrote:
> On Wed, May 25, 2022 at 1:49 AM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> > There are some display issues in some cases due to the "Confirm"...
> 
> Probably the same underlying issue as I recently reported with zle -M ... but
>   read -q confirm$'?\nConfirm? '
> might work more consistently.

Yes, it seems so.

> > Instead, if the condition is met, is it possible to remain in ZLE
> > with the current buffer, as if I didn't do accept-line?
> [...]
> > Or perhaps I could change the bindings to use a wrapper around
> > accept-line (ditto for accept-line-and-down-history).
> 
> Yes, this could be done as a wrapper.  If you want to try to keep it
> in zle-line-finish, replace
>   ... || BUFFER=""
> with
>   ... || { print -z $BUFFER && BUFFER="" }
> or similar.

But this has the effect to duplicate the line in the terminal.
For instance:

zira:~> echo foo                                                      <16:29:05
zira:~> echo foo                                                      <16:29:09
foo

> > zle -A accept-line real-accept-line
> 
> There's the built-in ".accept-line" widget for this sort of thing, so
> you don't have to create a new alias.

Is this documented?

When searching the man pages, I could find only one place where
such a built-in is used: in the example for recursive-edit.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




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