I'd like to remove a specific entry in my Zsh history.
Zsh's fc
and history
don't have any options to delete entries. I've tried looking for the ~/.zhistory
but that doesn't exist. How can I go about finding the location of the history file and remove the entry?
In my terminal, ZSH, there's a file called ~/. zsh_history , and a similar one for Bash. To remove the command, open that file and remove the entry from the list. Open a new terminal window, and the bad command is gone.
Removing history If you want to delete a particular command, enter history -d <line number> . To clear the entire contents of the history file, execute history -c . The history file is stored in a file that you can modify, as well. Bash shell users find it in their home directory as .
The -i option in sed allows for in-place editing. $ matches with the last lines of the file, and d is for deleting the selected line. Note that we can also open ~/. bash_history file with any text editor and delete the lines manually.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With