Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

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.
ghist.png




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. 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.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.