GREP_COLORS tool

Seems I’ve been all about the terminal customisation recently…

I use grep a lot. Multiple times every day without fail. I used ack for a while when I started at my current workplace as that seemed to be favoured by a lot of the existing devs there. However, I found that not having ack on some servers meant I was making silly mistakes when using grep elsewhere. Ever typed this:

and sat there waiting? Well I have. So I switched away from ack and became a grep advocate. This move from ack might also help explain my grep default flags, one of which (that I didn’t mention in that post..) is -P to use perlre in the search string.

As I also mentioned in that post, I configured my colours via GREP_COLORS. This wasn’t so much a major shift as I was using --color=auto but setting the highlighted word to a light background colour was definitely a great help, the other colours were just nice to keep the theme consistent. Setting these colours wasn’t particularly easy and a little painstaking, so I’ve set up a tool to help you customise your own GREP_COLORS variable with the settings you want. Want the match to flash so you definitely can’t miss it? Want to have grep results in the Window 3.1 hotdog style? No, right, of course not, but the point is you can!

The tool is available here and there’s also a github.io page if you prefer and the source is available on github.

Please share any styles you really like and I’ll add them to the links shown on the page.

Leave a Reply

Your email address will not be published. Required fields are marked *