Bash histoy – common history in different terminals

I have been looking to do this for sometime. The bash history is per
session basis and the last session to quit overwrites the bash_history
file and thus all other terminals started between the time last terminal
lasted does not get to write the commands in the history file. Secondly
the history gets cluttered with lot of duplicate entries and entries
with ls and cd commands. So finally I added these to the bashrc file:

#Ignore these commands for inclusion in the history file
export HISTIGNORE=\”history *:cd *:df *:exit:fg:bg:file
*:ll:ls:mc:top:clear:$HISTIGNORE\”
export HISTIGNORE=\”&:ls:[bf]g:exit:cd:history:*.bash_history\”
#append to the histofy file
shopt -s histappend
#Write the history immediately after the command execution
PROMPT_COMMAND=`history -a`
HISTCONTROL=ignoreboth
#Erase duplicates from history
export HISTCONTROL=erasedups