Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to add a type in ack

Tags:

ack

Everytime I try add a type in ack seem to fail i.e add a type (log) in ack

ack --type-set log:ext:log
ack: No regular expression found.

or

ack --type-add log:ext:log
ack: No regular expression found.

Anyone has a clue about this or it only

like image 805
Ratatouille Avatar asked Jul 24 '14 09:07

Ratatouille


Video Answer


2 Answers

If you want to try out a new type in place, then use a command like this:

ack --type-set proj:ext:csproj --type proj "some search pattern"

this will show you search results for the given type.

If you want to save the type permanently, then you have to add the following line to your $HOME/.ackrc:

--type-set=proj:ext:csproj

Two things to note:

  • The first command doesn't set the configuration permanently, only let's you try it.
  • The second line in the .ackrc file should have = (equals) instead of a space.

UPDATE (figured out from the Andy Lester's answer):

Instead of --type your_type_name you can just write shortcut --your_type_name.

like image 185
Sergey Kostrukov Avatar answered Nov 09 '22 22:11

Sergey Kostrukov


Do it like this:

ack --type-set=log:ext:log --log searchterm

or if you're trying to ignore log files.

ack --type-set=log:ext:log --nolog searchterm

If this log format is something you're going to refer to a lot, then you'll want to add the line to your .ackrc file. The arguments in your .ackrc get executed every time you run ack.

For more information, see "Defining your own types" after running "ack --man".

like image 29
Andy Lester Avatar answered Nov 09 '22 21:11

Andy Lester