After a reboot, I started seeing a message when loading the shell:
zsh: corrupt history file /home/myusername/.zsh_history
How can I recover from this situation and potentially recover some of the history?
After a reboot, I started seeing a message when loading the shell:
zsh: corrupt history file /home/myusername/.zsh_history
How can I recover from this situation and potentially recover some of the history?
Found a blog post describing a fix that appears to work for me, while restoring my missing history:
mv .zsh_history .zsh_history_bad
strings .zsh_history_bad > .zsh_history
Afterwards, you may want to instruct zsh to re-read the history form the recovered history file
fc -R .zsh_history
Simply removing random characters may also work:
vim .zsh_history
Remove any strange characters, which would most probably be near the end. (In my case I had a string of @ in the second last line, following a forced shutdown)
:x (save and exit)