Ack Is So Cool

By Morten Møller Riis

October 21 2011 14:15 CET

I use Ack A lot! It is so fast and easy to use rather than doing some grep -r ... line.

On OSX you can easily install it via the Homebrew project.

A small tip is to setup an ~/.ackrc file. Mine looks like this for some Rails magic:

               -a
               --ignore-dir=.git
               --ignore-dir=.bundle
               --ignore-dir=.sass-cache
               --ignore-dir=log
               --ignore-dir=tmp
            	

The -a option tells ack to search all files. The rest should be obvious :)

With this it is very fast to find something in your project eg.

               mmr@mmr-mbp ~/dnsapp/dnsapp (new_payment_system*) % ack min-height
               app/assets/stylesheets/_login.css.scss
               15:    min-height: 0px;
            
               app/assets/stylesheets/style.css.scss
               19://  min-height: 100%;
               268:  min-height: 600px;
               mmr@mmr-mbp ~/dnsapp/dnsapp (new_payment_system*) %

See? It even gives the file names and line numbers and unlike the above you actually get coloring for free. So I highly suggest you give ack a go if you are fed up with grep. There even exists some plugin for Textmate.