Delete specific line from Zsh history
Solution 1:
You are looking in wrong File. Look at ~/.zsh_history
not ~/.zhistory To view in which file your history is save
echo $HISTFILE
And
rm $HISTFILE
Solution 2:
Clearing Zsh History (oh-my-zsh)
- close, quit and re-open iTerm
- run
nano .zsh_history
- use the
arrow keys
to navigate to the part of your history you'd like to delete. - use the
delete
key to remove all unwanted history logs. - Once you've removed everything you'd like to remove, select
control X
toExit
. - You'll be prompted to
Save
the changes. If you're happy with your changes clickshift Y
. - You'll be asked where you'd like to save your changes. Select
control T
to saveto File
. - navigate to your
.zsh_profile
with yourarrow keys
and press enter. - Quit and restart iTerm.
- type
history
to confirm the deletions. - You've successfully cleared your Zsh history.
osxterminalzshoh-my-zsh
Solution 3:
Clear zsh history on unix systems.
echo "" > ~/.zsh_history & exec $SHELL -l