This post originated from an RSS feed registered with Ruby Buzz
by Robby Russell.
Original Post: Spice up your Terminal with colored grep pattern results
Feed Title: Robby on Rails
Feed URL: http://feeds.feedburner.com/RobbyOnRails
Feed Description: Ruby on Rails development, consulting, and hosting from the trenches...
Earlier, I came across a post by Garry Dolley, which he shows how to acheive colorized grep matches in bash. I recall having color matches when I used to use Linux on a daily basis as my primary work environment, but haven’t gotten around to setting this up on my MacBook, which is where I do almost all of my development work.
Before
If you don’t already have colors, a grep in your terminal might look something like the following screenshot.
While, I have a very small output here, this gets much crazier when you’re using egrep across an entire project. It’s hard to scan through all of the results for the inline pattern matches.
So, taking Garry’s suggestion (for bash), I did something similar with my favorite shell, Z shell.
Add the following to your ~/.zshrc file to begin experimenting with the colors.