Friday, June 19, 2015

Restore every command typed!

For all those software engineers out there, how many times have you wondered "There must be some command for this occasion" and completely forgot what it was.
To cope with those moments, especially when a new project is being set up,  shell script provides a cool and easy method to backup every command that is typed in it. Just put this in your bash profile or bashrc file.

export HISTCONTROL=erasedups
export HISTSIZE=25000
shopt -s histappend

cp /*home directory*/.bash_history /*home directory*/*backup directory*/"history.before.$(date +%F_%R)"


Now each and every command you typed would be in a backup. I go to the backup directory and grep with some pattern I slightly remember about the command I want to search. This saved me a lot of time. I hope this helps you too.

No comments:

Post a Comment