Closed davidhq closed 9 years ago
There are .js results because you have --js in your .ackrc, which puts --js on your command line.
Why do you think you need to have --ruby, --objc, etc in your .ackrc? They should not be there unless you always want to search --ruby, --objc etc.
Also I see you have .yml lumped under Ruby files. .yml is already included in --yaml, and you can say --noyaml. Run ack --help-types
for a listing.
Now I understand how .ackrc works... but:
I have --ruby
, --objc
and others in there so that .log and other stuff is not picked up... I now see that --nocss
is not neccessary because it gets excluded automatically as well.
But I still don't know how to include only --ruby
given my .ackrc... is there a better way to list what I'm interested in and still have the option of searching only in one type (--ruby
for example).
Thank you for .yml comment...
I'm also cleaning it a bit (coffee
for example is included)... I got this .ackrc from somewhere a long time ago and I think those type were not yet included in ack by default.
Don't put any types in your .ackrc. Then, when you only want Ruby, then specify --ruby on the command line.
What you may want to do is use the -k
flag to say "Only search the files that ack recognizes the types for". Otherwise, ack includes everything that is a text file. But with -k
, if it runs into a foo.xyz file, and that isn't recognized as a given type, then ack will ignore it. This is useful where you're searching trees that have lots of weird non-source files in it, like a lot of log files.
Finally, remember that you can have project-specific .ackrc files that work alongside the global ackrc file and any per-user ackrc files, too.
I see.
However I'd like it to use -k
by default because the search I tried now on a regular sized project was 7x faster with -k
... but when I include -k
then I again loose the ability to filter by only one type (--ruby
)... do you think this is a smart suggestion to be able to filter by specific types when using -k
mode?
I'm not sure I understand your last question.
It make sense your search might be 7x faster if -k
is excluding huge log files or some other huge text files.
Also, one trick for helping debug file selection is to use the -f
flag, with no regex, and see all the files that match the command line, so you could do: ack -f --ruby
and see all the Ruby files, or ack -k
and see all the files that are known types.
Yes, I know why it's 7x faster, makes sense... and I'd like to have it like this by default (so to include -k
option in .ackrc)
-f
is nice... maybe I can show you what I ment better using this:
I think ack -k -f --ruby
should not return this:
....
public/help.html
public/javascripts/tinymce_new/langs/readme.md
public/javascripts/tinymce_new/plugins/visualblocks/css/visualblocks.css
public/javascripts/tinymce_new/skins/lightgray/fonts/readme.md
public/javascripts/tinymce_new/skins/lightgray/fonts/tinymce-small.svg
public/javascripts/tinymce_new/skins/lightgray/fonts/tinymce.svg
Rakefile
script/rails
but this:
....
config/routes.rb
db/migrate/001_create_db.rb
db/migrate/20130427143408_add_tags_to_post.rb
db/migrate/20130501114358_migration_tags_not_null.rb
db/migrate/20130629121316_add_last_links_to_user.rb
db/schema.rb
deploy/before_restart
lib/tasks/convert.rake
public/dispatch.rb
Rakefile
script/rails
I solved the issue for me by creating this bash function:
function ack {
if [[ $@ == *--* ]]; then
command ack "$@";
else
command ack -k "$@";
fi
}
But I feel this should be the default... maybe I'm wrong and you know much better.. but for now I'll use this because it work perfectly. Thank you for your help and fast responses.
I have ack 2.14 and when I run
ack --ruby something
there are also .js results... :(my .ackrc: