15-Apr-2014
NOTE: This article is 3 years or older so its information may no longer be relevant. Read on at your own discretion! Comments for this article have automatically been locked, refer to the
FAQ for more details.
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:
alias ghist='history|grep'
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.
-i
A quick disclaimer...
Although I put in a great effort into researching all the topics I cover, mistakes can happen.
If you spot something out of place, please do let me know.
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.
Igor Kromin
Other posts you may like...