Add time And Date To Your Bash History

This comes in very handy if your trying to track back when you had last run something.
To enable it just simply add export HISTTIMEFORMAT="%h/%d - %H:%M:%S " to your .bashrc file

echo 'export HISTTIMEFORMAT="%h/%d - %H:%M:%S "' >> ~/.bashrc

Then reload your .bashrc

source ~/.bashrc

Now when you run history you should get a output similar to the one below

502 Aug/12 - 13:48:31 tail -f /home/duffy/log/access.log
503 Aug/12 - 13:49:01 echo hello
504 Aug/12 - 13:49:24 more /var/log/syslog

Some other bash history tips

  1. The best way of finding something quickly in your bash history is simply by pressing ctrl+r and then typing out the start of the command it will auto complete it with any matches found in your bash history
  2. If you don't want to save duplicate commands in your bash history simply add export HISTCONTROL=ignoreboth to your .bashrc
    echo 'export HISTCONTROL=ignoreboth' >> ~/.bashrc
  3. If you want to change the lenght of history add export HISTSIZE=1000 to your .bashrc
    echo 'export HISTSIZE=1000' >> ~/.bashrc

Comments

Popular posts from this blog

Can VLC 1.0 change the world?

Manage your Active Directory from Linux with adtool

ISRO All Set To Launch Bhuvan Mapping Service Today!