Color grep for Windows

Looking for color grep for Windows? I was. I didn’t find exactly what I was looking for; instead, I found something better.

ack is a tool like grep, designed for programmers with large trees of heterogeneous source code.

ack + FAR screenshot

ack doesn’t enable or output colors on Windows by default. To get it all working, do the following:

  1. If you don’t have it yet, get ActivePerl.
  2. Download the standalone version of ack; save it with a .pl extension
  3. Create a batch file somewhere under %PATH% named ack.bat which invokes perl with ack:

    @C:\Perl\bin\perl.exe C:\Tools\ack-standalone.pl %*

    You should now be able to type ack arguments from anywhere, however this won’t get colors working right away. To do that:

  4. Install the Win32::Console::ANSI module using PPM (you’ll need to add the repository).

  5. In ack-standalone.pl, add this line after the other two use lines:

    use Win32::Console::ANSI;

  6. Create a file named .ackrc in your user profile folder (usually C:\Documents and Settings_Username_), with the contents:

    bold red

    bold red” (which actually means bright red) is my own preference; I think it’s nicer than the default “black on_yellow”, and the default color for grep (on *nix) as well.

That’s it!