Eternal Bash history 

This single snippet, when put in a .bashrc, will instantly improve the productivity of any developer. Too bad it’s not set by default! Just imagine if any server that you ssh to would have it!

export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
export HISTFILE=~/.bash_eternal_history
export HISTCONTROL=ignoreboth:erasedups

bash_prompt() { history -a }
PROMPT_COMMAND=bash_prompt

However, this only ignores consecutive duplicate commands. If we want to clean up the history by leaving only unique commands we have to do it manually (or schedule it via cron):

cp $HISTFILE /tmp/.bash_history_backup
tac /tmp/.bash_history_backup | awk '!x[$0]++' | awk '/^#/&&f{next;} {if ($0~/^#/)f=1;else f=0}1' | tac > $HISTFILE
Here are my personal notes that hold no value to anyone except me.
Are they somehow offending you? Did I say something wrong or miss something?
I'm sorry! Please, leave a comment or contact me at t.me/baygeldin.