I've recently learned how to let ack support more filetypes (adding the following to .ackrc):


Unfortunately, that produces an info line on every ack search I use, even ones with 0 results.

$ ack --latte dump
ack: --type-add: Type "latte" does not exist, creating with ".latte" ...

Is there a way to make this a more permanent addition? (i.e. get rid of this info line) This looks to me like it's adding this new type on every ack call. Is it a problem with my installation of ack?

I'm on Mac OS X 10.5.8 with ack 1.92 (Running under Perl 5.10.1)

  • Regarding 10.6->10.5.8: I really have no idea why I wrote 10.6, I've always had 10.5.8... And when I realized it, I changed it... – Martin Tóth Feb 28 '11 at 14:51
  • 1
    Odd revision history: @Mehper started editing within the 5 minute grace period, and then (after Mehper started, but before he saved) Martin changed "10.6" to "10.5.8". Next, the change was undone when Mehper saved the edits to the (then) older text — which for the history was still the same revision due to the grace period, hence listing Mehper as changing the version. If you're bothered about this, then consider voting for After saving, alert when post was meanwhile saved by someone else. – Arjan Feb 28 '11 at 15:12
  • +1 I was using --type-set following the documentation but had no idea the types should be in a new line – Marcelo Diniz Mar 2 '13 at 18:14

Seems to me that the documentation claims you need --type-set instead:


Whereas --type-add is for, emphasis mine:

Files with the given EXTENSION(s) are recognized as being of (the existing) type TYPE.

  • 1
    +1 It also says "If you want to define a new type, or completely redefine an existing type, then use --type-set." – Dennis Williamson Feb 28 '11 at 14:26
  • Hmmm... I've read that section quite a few times, but I did not realize/understand, that I suits my needs! Thanks! – Martin Tóth Feb 28 '11 at 14:53

Hmmm... ack is basically a Perl script... which is quite easy to edit:

%mappings = (
    actionscript => [qw( as mxml )],
    ada         => [qw( ada adb ads )],
    latte       => [qw( latte )],
    yaml        => [qw( yaml yml )],
    xml         => [qw( xml dtd xslt ent )],

But still, is there another solution to this?

  • 4
    If you edit ack-grep itself you lose the benefit of subsequent upgrades because upgrading would overwrite your changes. The configuration can be done in .ackrc which is a superior solution. – Niels Bom Oct 19 '12 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.