Here’s a tiny little snippet that I have in my .bashrc which really comes in handy when trying to figure out what I did on a system when. One of the first things I do when (eek) building out or working on a one-off machine (or setting up a new laptop/desktop, as I am right now) is set this in bashrc for my user and root, so I can go back and document the setup process with a little more ease and sanity. Just add this (it’s just a strftime (3) format string according to the docs, so adjust as desired) to .bashrc:


and bash will store commented-out integer timestamps before each line in .bash_history like so:

less .bashrc
tail -30 .bash_history 

the output of history now uses the specified time format:

 997  2013-06-11 07:26:45 less .bashrc
 998  2013-06-11 07:26:57 history 
 999  2013-06-11 07:31:19 tail -30 .bash_history 
1000  2013-06-11 07:31:33 exit


comments powered by Disqus