Ack - better than grep, a power search tool for programmers
betterthangrep.com
betterthangrep.com
alias ack='ack-grep'
http://github.com/aristus/ack-shell
$ acksh ack
1) ./ack-shell/ack-shell
2: ## iack (interactive ack)
15: prompt = 'ack> '
44: cmdline[0] = 'ack'
ack> open 1 44> grep -r unicorn .
./config/unicorn/unicorn_build.rb: logger unicorn_logger
./config/unicorn/unicorn_build.rb: old_pid = '/home/rails/xxxxx/current/tmp/pids/unicorn.pid.oldbin
./config/unicorn/unicorn_production.rb: '/home/rails/xxxxx/current/tmp/pids/unicorn.pid.oldbin'
> ack unicorn
config/unicorn/unicorn_build.rb
10:# logger unicorn_logger
14:# old_pid = '/home/rails/xxxxx/current/tmp/pids/unicorn.pid.oldbin'
config/unicorn/unicorn_production.rb
15:# '/home/rails/xxxxx/current/tmp/pids/unicorn.pid.oldbin'
(in ~/.zshrc)
# 'ff' command -- find string in files with a specified suffix
ff() {
[[ -n $1 && -n $2 ]] || {
echo "Usage $0 [suffix] [string]"
echo "Where"
echo " suffix file suffix (without wildcards)"
echo " string string to search for (quote if spaces)"
return
}
find . -name \*$1 -exec grep -Hn $2 "{}" \; | less -RFX
}
Has colorized output, and only pages (with less) when there is more than one page to show. ack --type-set objj=.j
Doesn't work. I can append that to a query: ack CPWindowController --type-set objj=".j"
And it will search .j files for CPWindowController, but then it immediately forgets .j and the objj type. --type-set
objj=.j
I found this on the ack-grep man-page in Ubuntu. You can set the ACKRC environment variable to give it a different directory (besides ~) to search for your .ackrc. Each line of the .ackrc is a command-line arg that will be prepended to any specified arguments every time you run ack-grep. If you don't want those arguments for a particular query, pass the --noenv flag to ignore the .ackrc. HTH! --type-set=scala=.scala # works in .ackrc
--type-set scala=.scala # doesn't work in .ackrc
...despite the version with one equals being correct command-line sequence. Only seems to matter if you want each flag on a single line in your .ackrc file. Might not be true for everyone.But there's also (last I looked, may be more now): http://www.rooijan.za.net/?q=ack_el
(M-x rgrep in Emacs == grep -r everywhere else)
Emacs' rgrep DIR PATTERN REGEX translates to
find DIR \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS \
-o -path \*/MCVS -o -path \*/.svn -o -path \*/.git \
-o -path \*/.hg -o -path \*/.bzr -o -path \*/_MTN \
-o -path \*/_darcs -o -path \*/\{arch\} \) -prune \
-o -type f \( -name PATTERN \) -print0 \
| xargs -0 -e grep -i -nH -e REGEXThat being said, performance comparisons would be interesting. Not necessarily from a "which is better" standpoint, but from a "what can these projects borrow from each other", assuming it's not a straight port.