Closed stephenmckinney closed 10 years ago
This would be most welcome! This morning I started an experiment - replacing ack
with ag
(both in my shell and in Vim via ack.vim
) and I already miss being able to only search certain file types. Especially when I can categorize kinds of files:
# ~/.ackrc
--type-add=ruby=.haml,.rake,.builder
--type-add=html=.erb,.haml,.slim
--type-add=css=.scss,.sass,.less
--type-set=sass=.scss,.sass
Allowing for ack foobar --css
to only search CSS-like files (.css
, .scss
, .sass
, and .less
in this case).
While using Ack, I thought I was using the file type switch simply to speed things up, now that I'm using ag I find I need it to narrow results. Even if those results are returned much faster.
I never used this feature in Ack, which is why I didn't write it in Ag. I'd like for it to exist, but I'm not sure of the best way to go about it yet. Adding search by file-type would be a pretty big change. While Ag has plenty of code for blacklisting/ignoring, it doesn't have much whitelisting. I'll give this problem some more thought.
One more thing: I'm going on vacation for the next couple of weeks. I doubt I'll be online much.
@ggreer
I never used this feature in Ack, which is why I didn't write it in Ag.
That's certainly fair. I wish I could be of more help with implementing a feature like this, but it's been a long time since I last flexed by C
muscles.
Have a great holiday!
For now, I'm using bash globbing with ag, which I presume is going to be much slower. E.g:
shopt -s globstar
ag main-menu **/*css
Yeah this is sort of a deal breaker for me. When you said "replacement" for grep & ack but no mention of file types... (I had to really search for this issue), I wouldn't say it's a replacement, definitely a fast alternative though.
For basic extension-based type stuff, I've been using aliases with -G, personally. E.g.:
alias bbag="ag -G '\.(bb|bbappend|inc|conf)$'"
Not ideal, but it gets the job done for now, until ag gets better file type support.
I agree I've got many customs file types in my .ackrc
. This is a feature I'm missing in Ag
.
+1, this feature is essential when dealing with larger codebases.
Looks like #283 has implemented this.
Perhaps someone who know how it work could document this feature in the README, or perhaps in the Wiki?
Good shout @brondsem!
@stevenharman I've just upgraded my version of ag
, and it now emulates the way ack
works. So you can do—
ag --python tweets
To search for tweets
in Python files only.
I'm on it
Docs here: https://github.com/ggreer/the_silver_searcher/pull/327
Kevin Burke | Twilio phone: 925.271.7005 | kev.inburke.com
On Tue, Jan 21, 2014 at 5:26 PM, Beau notifications@github.com wrote:
Good shout @brondsem https://github.com/brondsem!
@stevenharman https://github.com/stevenharman I've just upgraded my version of ag, and it now emulates the way ack works. So you can do—
ag --python tweets
To search for tweets in Python files only.
— Reply to this email directly or view it on GitHubhttps://github.com/ggreer/the_silver_searcher/issues/128#issuecomment-32985043 .
This is great. Only thing is I can't find a method to add your own mapping ? E.g search only logs
Is there a way to print the list of filetypes? I know that we can view the source to see the list in the lang.c
file; however, it would be nice to have the equivalent of ack --help=types
.
I could have a look at listing the file types this evening if I get a chance. Should be quite a simple patch.
Have a look at PR #332 and tell me what you think.
@mcphail PR #332 looks great. Many thanks!
This issue seems closable in light of #283.
Oh yeah, totally implemented.
ag --list-file-types
Similar to ack, e.g. limit to Ruby files:
ag "layout" --rb