Fix : zsh corrupt error

Folks,

Recently I got an issue, whenever I open my terminal it shows some error that my .zsh got corrupt.

Somewhat like this :

$ zsh: corrupt history file /home/myusername/.zsh_history

How to fix this issue ?

This is due to some error in zsh history.

You just need to copy the following codes in your terminal :

$ cd ~

$ mv .zsh_history .zsh_history_bad

$ strings .zsh_history_bad > .zsh_history

$ fc -R .zsh_history

Now reboot your system

$ sudo reboot

                                                         Or

One of my senior suggested me that we don’t have to go so long, we can just simply delete our  ~/.zsh_history. To remove that just follow these codes –

echo $HISTFILE

And

rm $HISTFILE

 

Now that error won’t prompt you. #</HappycOding>