ggreer / the_silver_searcher

A code-searching tool similar to ack, but faster.
http://geoff.greer.fm/ag/
Apache License 2.0
26.07k stars 1.42k forks source link

Configurable file types as in ack #688

Open levsa opened 9 years ago

levsa commented 9 years ago

It would be nice with a configuration file where one can configure own file types, similar to what ack has.

fourcolors commented 9 years ago

I would actually like this as well. For instance, I need to tell the difference between "jsx" and "js" but right now you have to use --js which finds both js and jsx files.

carmelowoodgett commented 9 years ago

I actually came here looking to find documentation on this, hoping it was a feature already. I guess not, as of yet :)

ghost commented 9 years ago

Can configurate now? I want to find "aml" file,but there is not this file type,can i configurate it?

xmo-odoo commented 9 years ago

This seems to be a duplicate of #392 no?

zx8 commented 9 years ago

Yep - indeed a duplicate of #392 but this one seems more popular, so I'll add my +1 here. :smiley:

ghost commented 9 years ago

but how to add new file type fo ag ? i can not the above answer,can you help me ?

xmo-odoo commented 9 years ago

@hanyimin that's not currently supported hence this issue and #392, you can't add custom file types to ag in the way you do with ack. So you either use the -G, --include and --exclude flags explicitly (maybe with aliases e.g. alias agjs=ag --include='*.js' or you use something else or you add support for it and create a PR.

ghost commented 9 years ago

@xmo-odoo thanks, I think I can use the alias method ,thanks !

idning commented 8 years ago

+1, but --include is also nice!

mixmastamyk commented 8 years ago

--include ... doesn't work in my version, when did it appear?

I'd like to add support for restructuredText (.rst) but so far only "*.rst" on the command-line works.

bedge commented 8 years ago

The inability the define new file types in file search tooling, and therefore requiring a parallel but different set of aliases is definitely sub-optimal. As an example with ack, one of the almost 100 patterns I have is this: --type-add=deb-maint:is:preinst,postinst,prerm,postrm and sure, I could add an alias for that, but now I have to remember an alias for util 'a' and a file type name for tool 'b'. This doubles the amount of extraneous crap I need to keep in my ever shrinking head. If ag could be configured to use the same mappings, even if non-DRY on the config, the ability to use either utility and not have to remember 2 completely different set of file selection mnemonics would be big help.

MiguelLatorre commented 8 years ago

bedge: +1

jackson-dean commented 7 years ago

+1 I'm also running into a use case for this. Need to filter by handlerbars (.hbs) files.

richiethomas commented 7 years ago

Also need handlebars, since Ember relies heavily on it.

MightyCreak commented 7 years ago

I would also like to have this feature, we're using in-house file extensions in our project.

Level 0: same feature as Ack Level 1: handle extensions including a . (e.g. .generated.cs) Level 2: handle glob/pcre patterns in the extensions (e.g. .log\..*)

vzaliva commented 6 years ago

+1

dgrabla commented 6 years ago

+1

ErikSwan commented 6 years ago

Even worse; how is there not a built-in type for .txt files?

$ ag --version
ag version 2.1.0
$ ag --list-file-types | grep 'txt'
      .mas  .mhtml  .mpl  .mtxt
basvdheuvel commented 6 years ago

Argh, I was really hoping this feature would've been added by now. +1

EarthCitizen commented 5 years ago

I am shocked that this feature is missing!!

nathando commented 5 years ago

It will be a great feature to have!!

alfredbez commented 4 years ago

I switched to https://github.com/BurntSushi/ripgrep for this reason:

$ cat ~/.ripgreprc
--type-add
tpl:*.tpl
$ grep ripgrep ~/.zshrc    
export RIPGREP_CONFIG_PATH=$HOME/.ripgreprc
$ rg searchMe -ttpl # finds the string 'searchMe' in files with the extension 'tpl'
$ rg searchMe -Ttpl # finds the string 'searchMe' in files with an extension not equal to 'tpl'