Add timestaps to your bash history

bash history is very useful to access your past commands. Sometimes it would be just great to know when a command was typed to be able to correlate it to another event. Imagine we know that there was a change in a repository that might have fixed a heisenbug. But we know that not long ago, we saw the bug again. But are we sure it was before the change in the repository was made?

We can solve this (and other problems) by adding time stamps to our bash history. Add the following line to your .bash_profile file:

export HISTTIMEFORMAT="%d/%m/%y %T "

The meaning of %d, %m, etc are the usual ones. This way, when we type history the output will look like this:

508  06/01/16 17:59:34 history 
509  06/01/16 18:00:04 echo "hello"
510  06/01/16 18:00:07 history 


speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

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

*Required Fields