adding date to bash history command

Coming from Solaris to Linux, one thing I’ve missed for years was that the Linux bash history command doesn’t show timestamps. Thanks to my colleague, Shinn, I learned about this config settings that can go into .bashrc to solve that problem, and add a few other useful settings, as well. In Debian, the (system) file to modify is /etc/bash.bashrc, and /etc/bashrc in CentOS. Of course, user can modify her/his .bashrc.

export HISTTIMEFORMAT='%F %T '

Before:


355 vi .bashrc
356 history
357 history | wc -l

After:

355 2013-03-15 10:07:03 vi .bashrc
356 2013-03-15 10:07:17 history
357 2013-03-15 10:07:48 history | wc -l
358 2013-03-15 10:13:43 cat .bashrc
359 2013-03-15 10:57:46 exit
360 2013-03-15 13:22:12 history
361 2013-03-15 13:22:35 more .bashrc

export HISTSIZE=1000 – extends history from the default 500 most recent commands, to 1000.

export HISTCONTROL=ignoredups – removes duplicates from history
export HISTCONTROL=ignoreboth – I’m not sure about this one.

Please add other config options you find useful.