Colorized Grep Matches

Why I’ve been living without this until now is beyond me. I should have known grep had a color option to highlight its matches! Alas, I’ve been doing grep’s in grey this whole time.

Put this in your ~/.bashrc:

export GREP_OPTIONS='--color=auto'
export GREP_COLOR='1;33'
and weep the next time you do a grep.

‘1;33’ is bright yellow. Change the ‘1’ to a ‘0’ for the dark version of each color. Try values 30 through 37 for other colors.

A complete table of color codes can be found here:

Note: not all grep’s support this. I’m using “grep (GNU grep) 2.5.1” on OS X, YMMV.