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:
1 2 3 4 5 6 7 8 9 10 | #!/bin/sh # ack.sh ackrc="" if [ -f ./.ackrc ] then ackrc=$(tr '\n' ' ' < ./.ackrc) fi ack $ackrc $* |
1 2 3 | # ~/.bashrc alias ack="$HOME/bin/ack.sh" |
That’s it! Now I can create a .ackrc file at project root like this:
1 2 3 | --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