Ack

From wikinotes
Revision as of 17:56, 30 March 2020 by Will (talk | contribs) (→‎Configuration)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Ack (to me) is a much more convenient grep. It can be configured per-project, by default it uses coloured output, and shows a line-per-match within the file. It is a much more powerful tool than that, but that is how I most frequently make use it.


Usage

ack  <searchword>
ack --ignore-dir <directory> <searchword>

Ack can also store default arguments in .ackrc files. The default userfile is stored in the user's home, but every time that ack is run, it searches backwards from the current directory for any directory containing a .ackrc and applies any flags contained within it to the provided ack command.

Configuration

You can save ack commandline-flags in a .ackrc file. This can be saved within a directory, and it will be applicable to all subdirectories. This project-specific ackrc can be omitted with the commandline argument --noenv.

# example .ackrc file
--ignore-dir=site-packages/
--ignore-dir=tests/
--ignore-file=is:ctags   # exact filename match 'tags'