neither SHARE_HISTORY, INC_APPEND_HISTORY, INC_APPEND_HISTORY_TIME is good enough in my use case so i want to do the work in zshaddhistory: unsetopt SHARE_HISTORY zshaddhistory(){ local COMMAND_STR=${1%%$'\n'} print -r -- "$COMMAND_STR" >> $HISTFILE # from http://zsh.sourceforge.net/Doc/Release/Functions.html to avoid writing to $HISTFILE return 2 } but this results in duplicate entries to $HISTFILE how do I prevent the automatic writing to $HISTFILE?