Created
October 18, 2022 18:46
-
-
Save uilian/04d4be0d1cc961ee2d17472a3b74f472 to your computer and use it in GitHub Desktop.
Remove duplicates from zsh_history
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove duplicates from zsh_history: | |
$ cat -n .zsh_history | sort -t ';' -uk2 | sort -nk1 | cut -f2- > .zsh_no_duplicates_history | |
$ mv .zsh_no_duplicates_history .zsh_history | |
# In case of failure (i.e, `sort: Illegal byte sequence`), debug | |
# replacing the command above with `head`: | |
$ head -n 10000 .zsh_history | sort -t ';' -uk2 | sort -nk1 | cut -f2- | |
# Replace the number above in a binary search style until | |
# you find the culprit; then, remove the line and proceed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment