Ack: Difference between revisions

From wikinotes
 
No edit summary
 
Line 1: Line 1:
Ack (to me) is a much more convenient grep.
A [[grep]] alternative with some more convenient hotkeys.
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 =
= Usage =
<blockquote>
<blockquote>
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ack  <searchword>
ack  <searchword>
Line 20: Line 14:
and applies any flags contained within it to the provided <code>ack</code>
and applies any flags contained within it to the provided <code>ack</code>
command.
command.
</blockquote><!-- Usage -->
</blockquote><!-- Usage -->


Line 34: Line 27:
--ignore-file=is:ctags  # exact filename match 'tags'
--ignore-file=is:ctags  # exact filename match 'tags'
</source>
</source>
</blockquote><!-- configuration -->
</blockquote><!-- configuration -->

Latest revision as of 06:38, 19 July 2021

A grep alternative with some more convenient hotkeys.

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'