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 Tue, May 24, 2022 at 7:54 PM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
>
> On 2022-05-24 11:58:04 -0700, Bart Schaefer wrote:
\> >
> > You can add something to zle-line-finish() that compares
> > [[ $BUFFER = ${history[$HISTNO]} ]]
> > along with whatever your other criteria are.
>
> This doesn't seem to work. [...]
> Is the exit status of the function
> really taken into account to prevent the execution?

Sorry, I didn't mean to imply that was ALL you needed to do.

zle-line-finish() {
  if [[ $BUFFER = ${history[$HISTNO]} ]]; then
    local confirm
    read -q confirm"?Confirm: $BUFFER ?"
    [[ $confirm = y ]] || BUFFER=""
  fi
}

Or something that expands upon that.




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