Created
September 19, 2022 18:50
-
-
Save therevoman/a7532af575479f0a2b5edfbb0bef8212 to your computer and use it in GitHub Desktop.
deduped_bash_history
This file contains hidden or 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
| HISTCONTROL=ignorespace:ignoredups:erasedups | |
| shopt -s histappend | |
| HISTSIZE=-1 | |
| HISTFILESIZE=-1 | |
| #HISTTIMEFORMAT="[%Y%m%d %H%M%S] " | |
| HISTTIMEFORMAT="[%b %d,%Y %T] " | |
| PROMPT_COMMAND="history -a;${PROMPT_COMMAND}" |
This file contains hidden or 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
| function deduphistory { | |
| echo "deduphistory" | |
| history -w ~/.bash_history.dedup_backup | |
| history -n; history -a | |
| #history | sort --key=5 | uniq --skip-fields=4 | sort --key=1 | |
| tac ~/.bash_history | awk '!x[$0]++' | tac > ~/.bash_history_new_dedup | |
| history -cr ~/.bash_history_new_dedup | |
| history -w | |
| } | |
| # cleanup bash history on exit | |
| trap deduphistory EXIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment