Ack is a fantastic (and portable!) replacement
grep. It's aimed at programmers and by default will only search a
white-list of known file-extensions so that it will only search the “code” in a
ack looks at your
~/.ackrc file to get any customized “default” settings
you want. I use my (user-level)
~/.ackrc to enable some personalized default options,
e.g. color-ize output, always use a
$PAGER, sort the output by filename, etc.
But sometimes I want to have directory-level (or project-level) additional settings, namely to always exclude/ignore certain directories when searching at the project-level.
For example, here are the exclusions I want for my Octopress
So, I wrote-up a little
ack wrapper script: ack-wrapper.
It crawls the directory tree looking for an additional “local”
starting from the current working directory crawling up through any parent
directories until we find a
.ackrc file (or until we reach either
(Update 2012-03-10: It looks like Ack v2.0 supports PWD .ackrc files natively, and has some other neat enhancements to boot!)
- Grab the latest version of the ack-wrapper script,
drop it somewhere in your
$PATH(I like having a
~/bin/directory), and make sure it's executable (
chmod 755 path/to/ack-wrapper).
- Update your
alias ack=ack-wrapper, so that running
ack ...will first call the wrapper script, search for any “local”
.ackrcfiles, insert any additional options found into the original supplied command-line arguments, and finally call the (real)