talira

The Silver Searcher

A code-searching tool similar to ack, but faster

open sourceApache-2.0self-hostablefree

The Silver Searcher (ag) is a command-line tool for searching code, started as a clone of ack with a focus on speed. It skips files matched by .gitignore, .hgignore and its own .ignore file, searches files in parallel with pthreads, memory-maps files, and uses Boyer-Moore for literal strings and PCRE's JIT for regular expressions. Its author, Geoff Greer, describes it as quite stable, with most changes being new features, minor fixes or performance work; the latest release on its site is 2.2.0.

Ways to install

Problems it solves

  • ack is too slow when I search my whole code directory
  • search a repo for a string but skip everything in .gitignore
  • grep keeps matching minified JavaScript and vendored files I don't care about
  • find every place a function is called across a big codebase from the terminal
  • search code with a regular expression faster than grep -r
  • exclude extra paths from code search with an ignore file

Features

  • ignores patterns from .gitignore, .hgignore and .ignore
  • parallel search with pthreads
  • mmap()ed file reading
  • Boyer-Moore literal string search
  • PCRE JIT regular expressions
  • editor integrations such as ack.vim and ag.el

Capabilities

Has a command line toolplan not known

Alternatives

The same job

These do what The Silver Searcher does.

  1. ripgrep Searches directories recursively for a regex pattern, skipping gitignored files
  2. ast-grep A CLI tool for code structural search, lint and rewriting
  3. fd A simple, fast and user-friendly alternative to 'find'

Compare The Silver Searcher with the top 3