Code for Concinnity


Local/project-based .ackrc

If you use Ack, you may be annoyed by the fact that it only reads $HOME/.ackrc but not the project-local ./.ackrc.

It turns out it is quite easy to do it yourself by creating a simple shell script wrapper and then aliasing the ack command:

#!/bin/sh
# ack.sh
 
ackrc=""
if [ -f ./.ackrc ]
then
  ackrc=$(tr '\n' ' ' < ./.ackrc)
fi
 
ack $ackrc $*
 
# ~/.bashrc
 
alias ack="$HOME/bin/ack.sh"

That’s it! Now I can create a .ackrc file at project root like this:

--ignore-dir=tmp
--ignore-dir=logs
--ignore-dir=vendor

Now using this technique, one can easily create a wrapper than reads both $HOME/.greprc and ./.greprc and you get Ack’s functionality in grep! Now you wonder if we really need Ack at all 😛

Published by kizzx2, on July 11th, 2012 at 9:36 pm. Filled under: UncategorizedNo Comments

No comments yet.

Leave a Reply