When you pass no file name to ack, it operates on a built-in default set of files that excludes unrecognized binary files. If you do pass file names, it searches in all the files you pass. This explains the difference between
ack foo and
ack foo **.
In ack 1.x, use the flag
-a to tell ack not to skip files whose type it doesn't recognize.
You can make an alias if you want that flag more often than not: add the line
alias ack='ack -a' in your
~/.zshrc. If you set up this alias and want to call
ack without the option, call
\ack (the backslash disables alias expansion). Scripts are not affected by the alias, only interactive shells.
Alternatively, you can add the
-a option to your
Matches in binary files will be listed as “Binary file test1 matches”. There is no way to disable this behavior without modifying Ack itself (at least adding a plugin).
In ack 2.0, the
-a option has been removed. What you can do instead is to define a type that matches all files, and use the
-k option to make ack include all files of that type. Note that file types are processed in an unpredictable order, to this will cause a random set of binary types to be processed as ordinary instead of as the usual type.
ack --type-set='all:match:.*' -k foo
This way the matches are printed even for files that would otherwise look binary. As above, you can add these options to an alias or to your