Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ack — Ignoring multiple directories without repeating the flag

Tags:

ack

Is it possible to ignore multiple directories in Ack, without repeating the flag?

e.g. I know the following works (i.e. setting multiple flags):

ack --ignore-dir=install --ignore-dir=php 'teststring'

I was hoping that I could separate directories with commas, like I can do with the extensions as follows:

ack --ignore-file=ext:css,scss,orig 'teststring'

However, the following comma separated ignore flag doesn't work:

ack --ignore-dir=install,php 'textstring'

Is it possible to use some short-hand equivalent, so I don't have to repeatedly type out the --ignore-dir flag?

like image 669
SparrwHawk Avatar asked Dec 16 '13 17:12

SparrwHawk


3 Answers

It's actually similar to how you would specify the include patterns for grep:

ack <term> --ignore-dir={dir_a,dir_b}

However, This format does not work with a single directory. So

ack <term> --ignore-dir={log}

will not work.

like image 158
Mandar Pathak Avatar answered Nov 10 '22 13:11

Mandar Pathak


Since you're using ack 2, you can put --ignore-dir=install and --ignore-dir=php in a .ackrc file in the root of your project. Then, every ack invocation in that tree will use those flags.

like image 44
Andy Lester Avatar answered Nov 10 '22 12:11

Andy Lester


So to ignore single directory use

ack <term> --ignore-dir=dir_a

and to ignore multiple directories use

ack <term> --ignore-dir={dir_a,dir_b}
like image 26
Kaless1n Avatar answered Nov 10 '22 12:11

Kaless1n