A code-searching tool similar to ack, but faster.
A code-searching tool similar to ack, but faster.
A code searching tool similar to ack, with a focus on speed.
Do you know C? Want to improve ag? I invite you to pair with me.
ack..gitignore and .hgignore..ignore file. (*cough* *.min.js *cough*)ack, and all keys are on the home row!Ag is quite stable now. Most changes are new features, minor bug fixes, or performance improvements. It's much faster than Ack in my benchmarks:
ack test_blah ~/code/ 104.66s user 4.82s system 99% cpu 1:50.03 total
ag test_blah ~/code/ 4.67s user 4.58s system 286% cpu 3.227 totalAck and Ag found the same results, but Ag was 34x faster (3.2 seconds vs 110 seconds). My ~/code directory is about 8GB. Thanks to git/hg/ignore, Ag only searched 700MB of that.
There are also graphs of performance across releases.
mmap()ed instead of read into a buffer.pcre_study() before executing the same regex on every file.fnmatch() on every pattern in your ignore files, non-regex patterns are loaded into arrays and binary searched.I've written several blog posts showing how I've improved performance. These include how I added pthreads, wrote my own scandir(), benchmarked every revision to find performance regressions, and profiled with gprof and Valgrind.
brew install the_silver_searcheror
port install the_silver_searcherUbuntu >= 13.10 (Saucy) or Debian >= 8 (Jessie)
apt-get install silversearcher-agFedora 21 and lower
yum install the_silver_searcherFedora 22+
dnf install the_silver_searcherRHEL7+
yum install epel-release.noarch the_silver_searcherGentoo
emerge -a sys-apps/the_silver_searcherArch
pacman -S the_silver_searcher
Slackware
sbopkg -i the_silver_searcher
openSUSE
zypper install the_silver_searcher
CentOS
yum install the_silver_searcher
NixOS/Nix/Nixpkgs
nix-env -iA silver-searcher
SUSE Linux Enterprise: Follow these simple instructions.
FreeBSD
pkg install the_silver_searcherOpenBSD/NetBSD
pkg_add the_silver_searcherWin32/64
Unofficial daily builds are available.
winget
winget install "The Silver Searcher"Notes:
Chocolatey
choco install agMSYS2
pacman -S mingw-w64-{i686,x86_64}-agCygwin
Run the relevant setup-*.exe, and select "the_silver_searcher" in the "Utils" category.
Install dependencies (Automake, pkg-config, PCRE, LZMA):
macOS:
brew install automake pkg-config pcre xz
or
port install automake pkgconfig pcre xzUbuntu/Debian:
apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-devFedora:
yum -y install pkgconfig automake gcc zlib-devel pcre-devel xz-develCentOS:
yum -y groupinstall "Development Tools"
yum -y install pcre-devel xz-devel zlib-developenSUSE:
zypper source-install --build-deps-only the_silver_searcher
Windows: It's complicated. See this wiki page.
Run the build script (which just runs aclocal, automake, etc):
./build.shOn Windows (inside an msys/MinGW shell):
make -f Makefile.w32Make install:
sudo make installGPG-signed releases are available here.
Building release tarballs requires the same dependencies, except for automake and pkg-config. Once you've installed the dependencies, just run:
./configure
make
make installYou may need to use sudo or run as root for the make install.
You can use Ag with ack.vim by adding the following line to your .vimrc:
let g:ackprg = 'ag --nogroup --nocolor --column'or:
let g:ackprg = 'ag --vimgrep'Which has the same effect but will report every match on the line.
You can use ag.el as an Emacs front-end to Ag. See also: helm-ag.
TextMate users can use Ag with my fork of the popular AckMate plugin, which lets you use both Ack and Ag for searching. If you already have AckMate you just want to replace Ack with Ag, move or delete "~/Library/Application Support/TextMate/PlugIns/AckMate.tmplugin/Contents/Resources/ackmate_ack" and run ln -s /usr/local/bin/ag "~/Library/Application Support/TextMate/PlugIns/AckMate.tmplugin/Contents/Resources/ackmate_ack"
OpenSUSE tumbleweed install problems? (libpcre problems...)
ag output differs depending on whether it's invoked from a subshell or not
Use ugrep (ug) as a backend search engine to ag. It is the fastest search engine, it is mature and supports fuzzy search.
state project maintenance status
gitignore negation patterns are not honored for directories: * + !*/ ignores the entire repo
directory containing its own name in its `.gitignore` makes searches come up empty
[Bug] Segmentation Fault (NULL Pointer Dereference) in search_stream via getline
pattern location
Fails to search /etc without explicit listing it
[REQUEST] Replace library PCRE with PCRE2