I want to exclude some specific commands from saving into zsh history.
for e.g: exclude mpv/mpc commands from saving into zsh history regardless of setting HIST_IGNORE_SPACE
or not.
I found an answer here but it does not work when I test it.
command historyzsh
I want to exclude some specific commands from saving into zsh history.
for e.g: exclude mpv/mpc commands from saving into zsh history regardless of setting HIST_IGNORE_SPACE
or not.
I found an answer here but it does not work when I test it.
Best Answer
Consider a hook function to check the command before adding to the history file:
Quoting the section of the man page (
man zshmisc
, under "Hook Functions"):