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

2

8

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"
Recension answered 2/12, 2014 at 22:51 Comment(0)
R
6

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

alias ag="ag $* --pager 'less -R'"
Recension answered 2/12, 2014 at 22:51 Comment(2)
Worth noting that you can always add --nopager when invoking the command to override. This is useful for flags that don't play nicely with --pager 'less -R', such as --statsTarantass
Personally I like to use a different thing on the right hand side - alias ag="/bin/ag $* --pager 'less -R'" (where /bin/ag should be replaced with your location of the ag binary)Forever
K
-2

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

    -

Kahlil answered 19/4, 2016 at 14:2 Comment(1)
It looks like your answer is about ignoring files. I actually wanted to be able to adjust paging.Recension

© 2022 - 2024 — McMap. All rights reserved.