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
export HISTTIMEFORMAT=‘%F %T ‘
# 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“