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
Related Articles:
- 2010/03/02 Bash Sub Shells
- 2010/01/21 sed tutorial and help
- 2010/01/09 change the terminal title dynamically in X11
- 2010/01/03 Fedora 12 demonstrates sandbox for desktop applications
- 2009/12/24 query and downgrade selected packages based on version or repository
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.