Ack - bind the actual file name to the file type

For me, ack is a necessary kit (its nickname, and I use it a million times a day). It basically has everything I need, so I believe this behavior is covered, and I just can't find it.

I would like to limit it to specific file types with a type. the problem is that these files have the full file name and not the extension. For example, I would like to limit it to building files for buildr so that I can search for them with --buildr (Similarly applies to mvn poms). I have the following in my .ackrc

--type-set=buildr=buildfile,.rake 

The problem is that the "buildfile" is the full name of the file, not the extension, and I would like ack to exactly match that name. However, if I look at the types associated with 'buildr', this shows that the .buildfile is an extension, not the whole file name.

 --[no]buildr .buildfile .rake 

The ability to restrict a specific file name will be really useful for me, since there are many xml applications (e.g. ant build.xml or mvn pom.xml ) for which this would be ideal. I see that binaries, Makefiles and Rakefiles have a special type configuration, and maybe this is the way to go. I really would like to be able to do this, if possible, before resorting to user-defined functions. Does anyone know if this is possible?

+4
ack
source share
1 answer

No, you cannot do this. ack 1.x uses only extensions to determine file types. ack 2.0 will have much more flexible features where you can do things like:

 # There are four different ways to match # is: Match the filename exactly # ext: Match the extension of the filename exactly # match: Match the filename against a Perl regular expression # firstlinematch: Match the first 80 characters of the first line # of text against a Perl regular expression. This is only for # the --type-add option. --type-add=make:ext:mk --type-add=make:ext:mak --type-add=make:is:makefile --type-add=make:is:gnumakefile # Rakefiles http://rake.rubyforge.org/ --type-add=rake:is:Rakefile # CMake http://www.cmake.org/ --type-add=cmake:is:CMakeLists.txt --type-add=cmake:ext:cmake # Perl http://perl.org/ --type-add=perl:ext:pod --type-add=perl:ext:pl --type-add=perl:ext:pm --type-add=perl:firstlinematch:/perl($|\s)/ 

You can see which development on ack 2.0 works on https://github.com/petdance/ack2 . I would like to help.

+4
source share

All Articles