Skip to content

Instantly share code, notes, and snippets.

@arbal
Forked from musale/fix.md
Created February 6, 2024 22:03
Show Gist options
  • Save arbal/8f5aee644f31dc847479d6435345485c to your computer and use it in GitHub Desktop.
Save arbal/8f5aee644f31dc847479d6435345485c to your computer and use it in GitHub Desktop.
How to fix and recover a “corrupt history file” in zsh
# move to home directory
cd ~

# move the .zsh_history file into another .zsh_history_bad file
mv .zsh_history .zsh_history_bad

# write all printable strings into a new .zsh_history file
strings .zsh_history_bad > .zsh_history

# reload the history
fc -R .zsh_history

If you found this helpful, don't hesitate to buymeacoffee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment