

Improved searching with The Silver Searcher - andrewpthorp
http://thechangelog.com/searching-improved-with-the-silver-searcher/

======
aktau
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.

The silver searcher, would recommend.

------
nessus42
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+"$@"}

------
irrationalfab
The Silver Searcher is very good for using the terminal as an IDE.

I have two aliases which I find very helpful.

\- Search Obj-C files:

    
    
      alias ago='ag -G ".*\.(h|m)"'
    

\- Search Ruby files:

    
    
      alias agr='ag -G ".*.rb"'
    

Also if you are looking for an alternative to sed don't miss replace[1].

[1] <https://github.com/harthur/replace>

------
btipling
I wish ag were on linux boxes by default. Every time I instinctively try to
search via ag and am denied I wince as I type in grep instead. :(

------
djbender
From the github page (<https://github.com/ggreer/the_silver_searcher>):

    
    
      ack blahblahblah ~/code  6.59s user 1.94s system 99%  cpu 8.547 total
    
      ag  blahblahblah ~/code  1.39s user 1.81s system 229% cpu 1.396 total

------
tokanizar
I use this to search only php files

ag --stats -G ".*\\.php" SearchForThis

------
oacgnol
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.

------
scw
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.

------
Spiritus
How does "The Silver Searcher" translate to "ag"?

~~~
rson
The chemical symbol for silver is Ag. It's a stretch, but it's short so I'm
for it.

------
StavrosK
How does this differ from ack-grep?

~~~
andrewpthorp
It's faster than ack (according to their GitHub page), and it honors the
.gitignore/.hgignore by default, which is a nice feature!

