Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete specific line from Zsh history

Tags:

macos

zsh

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?

like image 339
Sten Kin Avatar asked Mar 31 '14 20:03

Sten Kin


People also ask

How do you delete ZSH history lines?

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.

How do I delete entries in bash history?

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 .

How do I delete multiple lines in Linux history?

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.


1 Answers

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 
like image 63
Amrit Dhungana Avatar answered Oct 19 '22 16:10

Amrit Dhungana