Search This Blog


Bash History

Add Timestamps to Bash History

vi $HOME/.bashrc

Add the following lines
# Setup timestamps for History
export HISTTIMEFORMAT="%h/%d -- %H:%M:%S "

Now when you type history each command will have a time-stamp attached:
 1117  Nov/28 -- 23:20:37 exit
 1118  Dec/02 -- 09:30:18 vi .bashrc
 1119  Dec/02 -- 09:32:23 history

Remove Duplicate Commands

# Ignore duplicate commands

Increase History Size

# Increase history lines to 10 000

Search History Dynamically

A useful tip that everyone should know is how to search history in place.
(reverse-i-search)`named': vi /var/named/
When you press ctrl+r it will bring up a reverse history search in which you can type a quick search query and it will bring up the most recent occurrence of that word that you have typed for quick execution.

No comments:

Post a Comment