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

Re: widget accept-no-history



I see, I wasn't aware of the zshaddhistory hook
thanks Bart

Pier Paolo Grassi


Il giorno gio 24 ago 2023 alle ore 05:20 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> ha scritto:
On Wed, Aug 23, 2023 at 7:41 AM Pier Paolo Grassi <pierpaolog@xxxxxxxxx> wrote:
>
> Years ago I created a widget that allows me to accept a line without committing it to the history:
[...]
> So I wonder, what would be a better implementation?

How about something along the lines of:

execute_no_history() {
  setopt hist_ignore_space
  zle .accept-line
}
zshaddhistory() {
  [[ -o hist_ignore_space ]] && return 2
}
precmd() {
  unsetopt hist_ignore_space
}

You can use a global variable instead of any otherwise-unused setopt
if you prefer.


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