ack-将实际文件名绑定到文件类型 [英] ack - Binding an actual file name to a filetype

查看:90
本文介绍了ack-将实际文件名绑定到文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对我来说,ack是必不可少的工具包(别名为a,我每天使用一百万次)。通常,它具有我需要的所有东西,所以我想知道这种行为已被掩盖,而我却找不到它。

For me ack is essential kit (its aliased to a and I use it a million times a day). Mostly it has everything I need so I'm figuring that this behavior is covered and I just can't find it.

我很想能够限制它使用一种类型的特定文件类型。问题在于这些文件具有完整的文件名而不是扩展名。例如,我想限制它为buildr生成文件,以便我可以使用--buildr搜索它们(类似的方法适用于mvn poms)。我在.ackrc

I'd love to be able to restrict it to specific kinds of files using a type. the problem is that these files have a full filename rather than an extension. For instance I'd like to restrict it to build files for buildr so i can search them with --buildr (Similar would apply for mvn poms). I have the following defined in my .ackrc

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

问题是'buildfile'是整个文件名,而不是扩展名,我希望ack完全匹配这个名字。但是,如果查看绑定到 buildr的类型,则表明.buildfile是扩展名而不是整个文件名。

The problem is that 'buildfile' is the entire filename, not an extension, and I'd like ack to match completely on this name. However if I look at the types bound to 'buildr' it shows that .buildfile is an extension rather than the whole filename.

--[no]buildr     .buildfile  .rake

限制为特定文件名的能力确实是这对我很有用,因为有很多xml用例(例如ant build.xml 或mvn pom.xml )完美。我确实看到二进制文件,Makefiles和Rakefiles具有特殊的类型配置,也许就是这样。我真的很希望能够在使用自定义功能之前,在可能的情况下做到这一点。有人知道这是否可能吗?

The ability to restrict to a particular filename would be really useful for me as there are numerous xml usecases (e.g. ant build.xml or mvn pom.xml) that it would be perfect for. I do see that binary, Makefiles and Rakefiles have special type configuration and maybe that's the way to go. I'd really like to be able to do it within ack if possible before resorting to custom functions. Anyone know if this is possible?

推荐答案

不,您不能这样做。 ack 1.x仅使用扩展名来检测文件类型。 ack 2.0将具有更加灵活的功能,您可以在其中执行以下操作:

No, you cannot do it. ack 1.x only uses extensions for detecting file types. ack 2.0 will have much more flexible capabilities, where you'll be able to do stuff 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)/

您可以在 https://github.com/petdance/ack2 。我希望得到您的帮助。

You can see what development on ack 2.0 is doing at https://github.com/petdance/ack2. I'd love to have your help.

这篇关于ack-将实际文件名绑定到文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆