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?
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
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
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.
I've found that --ignore
doesn't take a regex.
This should help:
ag --ignore="*_test.rb" "SomeAwesomeClass"
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.
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
For me, the following works (in ag
version 0.18.1):
ag --ignore TAGS;*.pdf;*.json "search_term"
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With