Adding new types with ack 3.6.0 on MacOS - No regular expression found.

9 views
Skip to first unread message

Konrad Szałwiński

unread,
Sep 2, 2022, 7:07:32 PM9/2/22
to ack users
Hi Forum,

I've tried adding types using all of the commands that I've found into to documentation and all over the Internet. Unfortunately I'm always the getting the same error: " No regular expression found."

For example:
konrad@Konrads-MacBook-Pro Users % ack --type-set=cypress:ext:ts
ack: No regular expression found.

Could anyone explain how to add new types with ack?

Kind regards,
Konrad 

Andy Lester

unread,
Sep 2, 2022, 7:12:10 PM9/2/22
to ack-...@googlegroups.com
> I've tried adding types using all of the commands that I've found into to documentation and all over the Internet. Unfortunately I'm always the getting the same error: " No regular expression found."
>
> For example:
> konrad@Konrads-MacBook-Pro Users % ack --type-set=cypress:ext:ts
> ack: No regular expression found.

When you specify a type on the command line, you still have to specify the rest of the things to search. It's not a permanent addition. So you could do:

ack --type-set=cypress:ext:ts --cypress pattern

and it would search only the cypress files for the pattern.

If you want cypress available always (which is probably the case), you add that --type-set to an .ackrc file. It could be your own personal ~/.ackrc file, or it could be a project-specific one.

For more about setting types in your .ackrc file, see the ack manual ("ack --man") and then find the section called "The .ackrc file" and "Defining your own types".

You can put types and other handy things in your .ackrc file. Here's what mine looks like:

$ cat .ackrc
--sort-files
--smart-case
--type-add=pytest:match:_test[.]py$
--type-add=pytest:match:^test_.*[.]py$
--type-add=jenkins:is:Jenkinsfile

I always want the files sorted, I always want to use --smart-case, and I have definitions for pytest and jenkins files.

Does that help?

Andy
Reply all
Reply to author
Forward
0 new messages