【问题标题】:How can I get ack to ignore *.orig files?如何确认忽略 *.orig 文件?
【发布时间】:2011-01-20 14:49:43
【问题描述】:

我把它放在我的 .ackrc 中:

--type-set=DUMB=*.orig
--noDUMB

...但我仍然在我的确认结果中看到 main.py.orig 之类的文件。我也试过--type-set=DUMB=*.*.orig,但也没有用。

更多信息

从我的命令行运行(OSX Snow Leopard with :

timmfin at lorien in ~/dev/performable/rafa on landing-pages-csv-and-more!
± ack modules --python | grep '.orig'
src/rafa/main.py.orig:25:import rafa.ui.modules.helpers
src/rafa/main.py.orig:26:from rafa.ui.modules.performable_form import PerformableForm
src/rafa/main.py.orig:27:from rafa.ui.modules.page_form import PageEditForm
src/rafa/main.py.orig:28:from rafa.ui.modules.settings_form import SettingsForm
....

timmfin at lorien in ~/dev/performable/rafa on landing-pages-csv-and-more!
± cat ~/.ackrc 
--color
--sort-files
--smart-case

--type-set=sass=.sass
--type-set=coffee=.coffee

--ignore-dir=rafa/static
--ignore-dir=compiled
--ignore-dir=compressed

--ignore-dir=venv
--ignore-dir=build

timmfin at lorien in ~/dev/performable/rafa on landing-pages-csv-and-more!
± ack --version
ack 1.94
Running under Perl 5.10.0 at /usr/bin/perl

【问题讨论】:

    标签: ack


    【解决方案1】:

    现在 ack 2.0 可用:

    --ignore-file=ext:orig
    

    ,在命令行或.ackrc

    可以按名称忽略文件。忽略 ctags 生成的文件:

    --ignore-file=is:tags
    

    不同用途的过滤器可以在documentation找到。

    【讨论】:

    • 我希望这将被更新为“接受的答案”,这是现在最好的方法!
    • 您可以使用match 和正则表达式来匹配文件名,使用ext 来匹配扩展名。排除js文件--ignore-file=ext:js。排除名称为 foo 和 bar --ignore-file='match:/foo|bar/' 的文件。在使用 | 的正则表达式的情况下,用引号转义参数,以便 shell 不会将其作为管道执行。
    【解决方案2】:

    对于 ack 版本 1.x

    如果我删除了星号(来自Ackmate wiki),我发现这有效

    --type-set=DUMB=.orig
    --noDUMB
    

    你可以通过运行查看ackmate支持的文件类型(包括你在~/.ackrc中指定的):

    ~/Library/Application\ Support/TextMate/PlugIns/AckMate.tmplugin/Contents/Resources/ackmate_ack --help type
    

    【讨论】:

      【解决方案3】:

      对于 ack 版本 1.x,请使用以下内容。就我而言,我想忽略 .css 文件。我必须设置名为 SOMETHING 的类型。然后将其设置为 --noSOMETHING 以将其从搜索中删除。

       ack --type-set=SOMETHING=.css --noSOMETHING "My Bitcoin."
      

      【讨论】:

        【解决方案4】:

        ack 一开始就无法识别 .orig 文件。我猜你是从ackrcACK_OPTIONS 调用ack -a

        【讨论】:

        • 我主要通过 Textmate 的 AckMate 插件使用 Ack(我不确定它使用了哪些选项,而不是我的 .ackrc),但我也从命令行中的 ack 看到了问题。更新了我的问题以获取更多详细信息
        • 试试 --noenv 看看你的 .orig 是否被忽略。另外,您的 ack 可以别名为 ack -a 吗?另外,使用 ack -f 获取 ack 感兴趣的所有文件的列表。
        • 我得到了 ack: Invalid option in ~/.ackrc
        • 您何时收到该错误消息?你在 ~/.ackrc 中做了什么?
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-11-13
        • 1970-01-01
        • 2014-05-24
        • 2020-03-14
        • 1970-01-01
        • 1970-01-01
        • 2021-01-13
        相关资源
        最近更新 更多