If you're like me and use the Terminal in OS X on a daily basis, you probably also use the 'history' command quite regularly too. Every time I use history I always pipe it through grep, so always, always end up typing 'history|grep blah', now isn't there an easier way? Well there is, and that's what the alias functionality is for.
I used the alias command in my ~/.profile
file to set up a new command alias called 'ghist' that will run the output of history through grep, this is set up like so:
With that set, all I have to do now is type 'ghist blah' to look through my history for anything I ran that included the text blah
in it. Simple really and quite useful.
Of course this same trick will work in pretty much any other flavour of Unix.
A quick disclaimer...
Although I put in a great effort into researching all the topics I cover, mistakes can happen.
Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.
All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle).
Use of any information contained in this blog post/article is subject to this disclaimer