To get an empty history, temporarily set HISTSIZEHISTSIZE to zero.
function erase_history { local HISTSIZE=0; } erase_history If you want to erase the new history from this shell instance but keep the old history that was loaded initially, empty the history as above then reload the saved history fc -R afterwards.
If you don't want the erase_history call to be recorded in the history, you can filter it out in the zshaddhistory hook.
function zshaddhistory_erase_history { [[ $1 != [[:space:]]#erase_history[[:space:]]# ]] } zshaddhistory_functions+=(zshaddhistory_erase_history) Deleting one specific history element (history -d NUM in bash) is another matter. I don't think there's a way other than:
- Save the history:
fc -AIto append to the history file, orfc -WIto overwrite the history file, depending on your history sharing preferences. - Edit the history file (
$HISTFILE). - Reload the history file:
fc -R.