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 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.

> 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.

> 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.

> zle -N accept-line accept-line-wrapper
>
> where $PS1 contains "%3v", and with psvar[3]="" in precmd().
>
> Could there be any issue? Or is there anything to add?

I don't see any particular problem with that approach.




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