How do I add a persistent configuration option to 'ag'?

1k Views Asked by At

I have recently begun to use the 'ag' command instead of 'ack'.

Ag is much faster, but does not seem to have a file (such as .ackrc) where one could add configuration options.

For example, I always want a pager to be used, and I don't want to have to always type in:

ag --pager "less -R"
2

There are 2 best solutions below

2
On BEST ANSWER

How about putting the following in your command line configuration file (such as .bashrc or .zshrc)?

alias ag="ag $* --pager 'less -R'"
1
On

Hope this is not way too late.

Run man ag on linux box. Right at the end if the following text:

By default, ag will ignore files matched by patterns in .gitignore, .hgignore, or .agignore. These files can be anywhere in the directories being searched. Ag also ignores files matched by the svn:ignore property in sub‐ version repositories. Finally, ag looks in $HOME/.agignore for ignore patterns. Binary files are ignored by default as well.

Note the part I emphasised. So just add .agignore file and ignore patterns in there

    -