Advanced Usage

Steven Harman edited this page Sep 6, 2017 · 22 revisions

Advanced Usage

Ignoring files

By default, Ag will read the patterns in .gitignore and .hgignore files in directories it searches. If your source control doesn't care about a file, why should your source-searching program?

Currently double asterisks ** patterns in .gitignore and .hgignore are not recognized. See this issue for details and workaround.

.ignore

You can also create .ignore files to ignore things that are in your source repository. .ignore uses the same patterns as .gitignore and .hgignore. Using .ignore can drastically improve search speeds. A common speedup is to ignore extern. If you want a global .ignore file, consider adding this alias: alias ag='ag --path-to-ignore ~/.ignore' to your ~/.bash_profile (or similar) file.

.agignore

The .agignore file was removed in favor of .ignore as part of the 2.0.0 release.

Ignoring from the command line

The -G option lets you specify a regex of file names to search. Any file name not matching this pattern will be ignored. For example, ag -G manager class will find instances of the string "class" in all files with the string "manager" in their name.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.