#!/bin/sh # Wrapper around 'ack' to crawl all directories from $PWD to / (or $HOME) # looking for a "local" .ackrc file. Useful for setting project-level # --ignore-dir settings. PWD=$(pwd) HOME=~ ack=$(type -P ack) ackrc="" match="" dir="$PWD" while [ "$dir" != "/" -a "$match" = "" ]; do if [ -e "$dir/.ackrc" ]; then if [ "$dir" != "$HOME" ]; then match=1 echo "(Include: ${dir}/.ackrc)" ackrc=$(egrep "^[^#]" "${dir}/.ackrc" | tr '\n' ' ') else match=0 fi else dir=$(dirname "$dir") fi done # Add quote-wrapping for any additional args to ensure proper passing to # real 'ack'. for arg in "$@"; do ackrc="${ackrc} '${arg}'"; done # Run the final command eval "${ack} ${ackrc}"