如何修改ack中的类型?
How can I modify a type in ack?
我知道如何设置新类型。我想要做的是修改现有类型。我想将 haml 文件添加到 ruby 类型。我可能会使用 --set-type 并重新定义 ruby 类型,但我不知道如何重新定义它并且仍然包含名为 'Rakefile' 的文件和第一行指示它是可执行文件的文件Ruby 脚本(第一行匹配 /^#!.*\bruby/)
这是 ruby 类型的现有文档:
ruby .rb .rhtml .rjs .rxml .erb .rake .spec; Rakefile; First line matches /^#!.*\bruby/
您可以使用三个参数来处理类型定义。来自 ack --help
:
File type specification:
--type-set=TYPE:FILTER:ARGS Files with the given ARGS applied to the given
FILTER are recognized as being of type TYPE.
This replaces an existing definition for TYPE.
--type-add=TYPE:FILTER:ARGS Files with the given ARGS applied to the given
FILTER are recognized as being type TYPE.
--type-del=TYPE Removes all filters associated with TYPE.
如果您只想将 .haml
文件添加到现有 Ruby 规范,请使用
--type-add=ruby:ext:haml
如果您想查看现有类型的定义方式,请使用 --dump
。
$ ack --dump | ack ruby
--type-add=ruby:ext:rb,rhtml,rjs,rxml,erb,rake,spec
--type-add=ruby:firstlinematch:/^#!.*\bruby/
--type-add=ruby:is:Rakefile
我知道如何设置新类型。我想要做的是修改现有类型。我想将 haml 文件添加到 ruby 类型。我可能会使用 --set-type 并重新定义 ruby 类型,但我不知道如何重新定义它并且仍然包含名为 'Rakefile' 的文件和第一行指示它是可执行文件的文件Ruby 脚本(第一行匹配 /^#!.*\bruby/)
这是 ruby 类型的现有文档:
ruby .rb .rhtml .rjs .rxml .erb .rake .spec; Rakefile; First line matches /^#!.*\bruby/
您可以使用三个参数来处理类型定义。来自 ack --help
:
File type specification:
--type-set=TYPE:FILTER:ARGS Files with the given ARGS applied to the given
FILTER are recognized as being of type TYPE.
This replaces an existing definition for TYPE.
--type-add=TYPE:FILTER:ARGS Files with the given ARGS applied to the given
FILTER are recognized as being type TYPE.
--type-del=TYPE Removes all filters associated with TYPE.
如果您只想将 .haml
文件添加到现有 Ruby 规范,请使用
--type-add=ruby:ext:haml
如果您想查看现有类型的定义方式,请使用 --dump
。
$ ack --dump | ack ruby
--type-add=ruby:ext:rb,rhtml,rjs,rxml,erb,rake,spec
--type-add=ruby:firstlinematch:/^#!.*\bruby/
--type-add=ruby:is:Rakefile