Bash histoy – common history in different terminals

2010-03-04 117 words 1 min read

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


author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it