deleting single entry from history in zsh -- Terminal
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):
setopt HIST_IGNORE_SPACE
LC_ALL=C sed -i '' '/PASSWORD/d' $HISTFILE
- 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!