Skip to content

Instantly share code, notes, and snippets.

@Sp0ne
Last active September 15, 2021 21:56
Show Gist options
  • Save Sp0ne/91623d7185f6e7efa7590979b833734f to your computer and use it in GitHub Desktop.
Save Sp0ne/91623d7185f6e7efa7590979b833734f to your computer and use it in GitHub Desktop.
Fixes a corrupt .zsh_history file
#!/bin/zsh
# --
# Vinces - https://vinces.io
# --
# Fixes a corrupt .zsh_history file:
# ➜ cd Folder && zsh fix-corrupt-zsh-history.sh
# 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 -eS ~/.zsh_history_bad > ~/.zsh_history
# reload the history
fc -R ~/.zsh_history
# remove bad history backup
rm ~/.zsh_history_bad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment