Just the other day I realized I was using the OS X stock grep
, which was
lacking a few features I wanted, some features in particular are the ability to
fully color highlight grep results with the --color
option, or to exclude
directories from searches using the --exclude-dir
option.
I was shocked to find one of the first results in google was my own blog from when I previously wrote about this back in March.
Well, the old method for upgrading grep using homebrew no longer works. Luckily I found a post on superuser which describes a new method for upgrading grep via homebrew.
brew tap homebrew/dupes
brew install homebrew/dupes/grep
Note that the new grep will install to /usr/local/bin
which usually appears
after /usr/bin/
which contains your stock OS X grep, giving priority to the
OS X grep.
You can either finagle the paths in your ~/.profile
or ~/.bash_rc
or do as I
did and create a one-off alias for any OS X duplicate software you’ve installed,
which I feel gives more control over switching it on and off if you need to for
some reason.
alias grep='/usr/local/bin/grep --color'
Another bonus to using this method is that it will put the duplicated packages
you are currently using in plain site in your ~/.profile
.