Enhance your Bash History

I have always wanted to do such thing, but never found a solution that worked.

I was amazed with the simplicity of this:

  • longer history
  • datetime formatted
  • history appended across multiple terminals
  • no duplicated stuff (for repeated commands – this is not so useful if you monitor history, such as in servers, but for end-user machines, it is awesome!)
Just add the following to your ~/.bashrc file:

# Improve History command
# Sources:

# time entry for .bash_history

# eliminate continuous occurrences duplicates
export HISTCONTROL=ignoredups 

# big big histfile
export HISTSIZE=100000 

# append to history, don’t overwrite it 
shopt -s histappend 

# Save and reload the history after each command finishes
export PROMPT_COMMAND=“history -a; history -r; $PROMPT_COMMAND

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>