Reputation: 4804
According to the docs, it should be
--ignore PATTERN
I have a file containing tags, named "tags". I have tried the following, each of them still searches through the tag file..
ag -Qt --ignore ".*tags" "asdf"
ag -Qt --ignore .*tags "asdf"
ag -Qt --ignore "tags" "asdf"
ag -Qt --ignore tags "asdf"
ag -Qt --ignore *tags
and none of them works.
If I use what's suggested here, then ag doesn't accept it at all
I tried to work around it by renaming it to temp.tags and using *.tags
pattern to try and ignore it, but it still doesn't work.
Any ideas?
Upvotes: 56
Views: 25530
Reputation: 35984
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. .
If you want a global .ignore file, consider adding this alias:
alias ag='ag --ignore ~/.ignore'
to your ~/.bash_profile
(or similar) file. there is also
to temporarily disable vcs ignores you can run with --skip-vcs-ignores
Upvotes: 2
Reputation: 2827
I just placed .agignore file into my user root folder and it works.
By default, ag will ignore files matched by patterns in .gitignore, .hgignore, or .agignore. These files can be anywhere in the directories being searched. Ag also ignores files matched by the svn:ignore property in subversion repositories. Finally, ag looks in $HOME/.agignore for ignore patterns. Binary files are ignored by default as well.
https://manpages.ubuntu.com/manpages/trusty/man1/ag.1.html
Upvotes: 1
Reputation: 3286
As of v2.2.0 (most likely earlier versions as well; I'm just going off the version I have) all these answers don't seem to work. What did work for me was:
ag searchterm --ignore=*.log --ignore=*.txt
Note the =
after the ignore
option.
Upvotes: 5
Reputation: 1506
I've found that --ignore
doesn't take a regex.
This should help:
ag --ignore="*_test.rb" "SomeAwesomeClass"
Upvotes: 17
Reputation: 1139
Put the list of files to exclude in .agignore
.
Note: as @DenilsonSáMaia mentioned, .agignore
will be deprecated in favor of .ignore
geoff.greer.fm/2016/09/26/ignore
Upvotes: 44
Reputation: 2159
Have you tried using single quotes? I know i've definitely been stumped by using double quotes and no quotes only to find that single quotes worked.
ag -Qt --ignore '*tags'
Upvotes: -1
Reputation: 393
Add just multiple --ignore, at least this works for me:
ag -Qt --ignore ".*tags" --ignore asdf
If you don't put quotes it's interpreted as directory if you put quotes as PATTERN
Upvotes: 23
Reputation: 1405
For me, the following works (in ag
version 0.18.1):
ag --ignore TAGS;*.pdf;*.json "search_term"
Upvotes: 1
Reputation: 511
I tried the link you posted (using a glob instead of regex), but removed the '=' sign, and it worked.
Upvotes: 0
Reputation: 4804
After some research, it seems that it is a known issue documented here. Where if you do an --all-text (-t) search it'll override --ignore since it's searching for all texts. This issue is present for --unrestricted too.
Upvotes: 12