When often using the terminal you don’t want to type certain commands over and over again. Although recent commands are stored in the .bash_history
in your home-directory they will be overwritten at some point when a new terminal is opened. So you won’t be able to use Ctrl + R
to search for commands you’ve typed longer time ago.
Luckily there is an option to append the terminal commands instead of overwriting them.
$ shopt -s histappend
Add this command to your ~/.bash_profile
and you’ll never lose a command anymore.
As a side effect the .bash_history
file will grow over time as well as be poluted with a lot of redundant commands.
So i wrote a little ruby script to keep the ~/.bash_profile
commands unique.
Here we go..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
You can use and/or modify it to your own needs. Maybe there is someone of you who’s running Ruby on an Windowz machine and could implement an appropriate modification and post it back?
That’s it, more simple ruby stuff to come..
Thanks for reading and feel free to leave a comment.
~ David
Update: I added some error handling for the case the history does not exist.