Is there a straight forward way of deleting a single entry from the shell history in the "new" zsh shell?

I know fc does not support this and I can't even figure out where Apple now stashes the history file (to cope with multiple terminal sessions).

1 Answer 1


You can either use:

open $HISTFILE && exit

which usually opens TextEdit (or another default text editor - depends on your environment) and remove the line (and the last temporary line containing something like : 1583100426:0;open $HISTFILE && exit) and save the file ("Save Anyway").

or - if you know some exclusive content of the line (in my example below PASSWORD):

  • the first command sets the option to not add commands prepended by spaces in the history file
  • the second command (prepended by a space!) removes all lines containing PASSWORD from the history file

Both commands won't remove unwanted lines in zsh history files in e.g. Time Machine backups!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .