Specify ignore custom file patterns in .ackrc
Asked Answered
H

2

24

I have certain CSS files of fileName *-c.css and *-gen.css which I want to ignore from ack-grep searches.

I see that --type-set=TYPENAME=.extension does not accept regex filters like *-c.css, any idea of how to get around this problem ?

Hawkes answered 16/10, 2013 at 21:59 Comment(0)
H
44

I came across ack-grep 2.0 which provides --ignore-file option based on regex pattern as below and it worked after adding it to ~/.ackrc.

--ignore-file=match:-c.js
--ignore-file=match:-gen.js
--ignore-file=match:-c.css
--ignore-file=match:-gen.css
Hawkes answered 18/10, 2013 at 20:44 Comment(3)
for exact file names: --ignore-file=is:<filename> - for ctags file: --ignore-file=is:tagsCouncilwoman
Filters for different uses can be found on beyondgrep.com/documentation/…Councilwoman
For all the too-fast readers finding this: Note that the '-' in the match string above is not saying "remove c.js files" - the '-' is part of the file name in the original question!Surge
H
1

Use a regular expression to filter those files you want to search.

ack -G '(?<!-c)(?<!-gen)\.css$' expression_to_search

It uses the perl flavour. I do a negative look-behind to skip those that contain -c or -gen just before the extension.

Hick answered 17/10, 2013 at 11:17 Comment(1)
For those reading this in 2019 or beyond, ack 3.x doesn't support the -G option. You have to use ack -g pattern | ack -x expression_to_search.Elissaelita

© 2022 - 2024 — McMap. All rights reserved.