I've been using it for the past week (on my mac, homebrew is such a joy to use most of the time) and I absolutely love it. Before this I often had to type grep -lir "somestring" *, to recursively search in a project. Which would be often slow (reading huge binary files, ...) and is a handful to type. Admittedly I could've made an alias, but then I still would've had the binary file problem.
Now I can do
ag "somestring"
And out comes beautifully colorized output in the blink of an eye telling me where and what. In short it comes with sane defaults for code searching and is faster than grep, what's not to like?
I fruitlessly tried ack once before and it never worked out for me, but this is staying in my toolbox.
Not that I have anything against The Silver Searcher, but I've been using the following script I wrote for years, and it is even faster than ag from my very recent limited experience:
#!/bin/sh -u
dir="$1"
shift
# This doesn't work unless we have GNU find (for the -xtype option):
gfind "$dir" \
\( -type f -or -xtype f \) \
\( -name "*.[ct]xx" \
-or -name "*.[CchH]" \
-or -name "*.py" \
-or -name "*.java" \
-or -name "*.scala" \
-or -name "*.pde" \
-or -name "*.js" \
-or -name "*.xml" \
\) \
-print0 \
| xargs -0 egrep ${1+"$@"}
I use both ag and ack interchangeably and one thing I wish is that ag would be 100% compatible with ack options. It'd be nice to just do a s/ack/ag and expect things to work.
I've been using ag for the past year or so, and it's great. One pain point remains the lack of Windows support, so I'm back to double-slow cygwin grep when on Windows.
With Ack, I had to set up a bunch of --type-add lines to ~/.ackrc so that Ack wouldn't ignore e.g. SCSS files. ag searches every file by default, except for VCS files (e.g. .git/ and .hg) and files that are ignored by your VCS.
Ag's default behavior is way better, and less confusing to new users. Plus, it's faster.
Now I can do
And out comes beautifully colorized output in the blink of an eye telling me where and what. In short it comes with sane defaults for code searching and is faster than grep, what's not to like?I fruitlessly tried ack once before and it never worked out for me, but this is staying in my toolbox.
The silver searcher, would recommend.