Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how create a preference file? #111

Closed
slimane opened this issue Nov 19, 2012 · 7 comments
Closed

how create a preference file? #111

slimane opened this issue Nov 19, 2012 · 7 comments

Comments

@slimane
Copy link

slimane commented Nov 19, 2012

one question, how create a .ackrc style preference file?

@ggreer
Copy link
Owner

ggreer commented Nov 21, 2012

Ag doesn't support this. Instead, you can try using aliases. Also, .agignore files can come in handy.

I'm loathe to add support for a ~/.agrc. The complications are numerous and it doesn't add anything that aliases can't do.

@ggreer ggreer closed this as completed Nov 21, 2012
@jfelchner
Copy link

@ggreer Sorry to bring this up again after 2 weeks but I didn't want to create a new issue. So my .ackrc looks like this:

--type-add=ruby=.haml,.rake,.ru,.rsel,.builder,.rb,.gemspec,.palette
--type-add=vim=.vim,.snippets
--type-add=html=.html,.html.erb,.html.slim,.html.haml,.mustache,.jst,.ejs
--type-add=js=.js,.coffee,.js.erb
--type-add=css=.sass,.less,.scss
--type-set=cucumber=.feature
--type-set=markdown=.markdown,.md
--type-set=sh=.env,.aliases,.plugin,.completion,.theme,.compdef,.zsh,.sh
--ignore-dir=vendor
--ignore-dir=doc
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=coverage
--ignore-dir=public/assets
--ignore-dir=public/system
--ignore-dir=public/coffeescripts
--sort-files
--color
--follow
--group
--smart-case

Now obviously the ignore-dir stuff can go away which is awesome:

--type-add=ruby=.haml,.rake,.ru,.rsel,.builder,.rb,.gemspec,.palette
--type-add=vim=.vim,.snippets
--type-add=html=.html,.html.erb,.html.slim,.html.haml,.mustache,.jst,.ejs
--type-add=js=.js,.coffee,.js.erb
--type-add=css=.sass,.less,.scss
--type-set=cucumber=.feature
--type-set=markdown=.markdown,.md
--type-set=sh=.env,.aliases,.plugin,.completion,.theme,.compdef,.zsh,.sh
--sort-files
--color
--follow
--group
--smart-case

But the rest of it is a lot of stuff to put into an alias and it'll also make it quite a bit less readable. Am I doing something wrong with all the type-add stuff? Is that not needed in ag?

@moll
Copy link

moll commented May 22, 2014

A config file could help set personal sensible defaults where ag is not executed by hand from the shell, but as (sub)process from elsewhere such as from a text editor. Duplicating and keeping options equal everywhere is a little cumbersome. Creating a separate custom wrapper would be a work-around, but I'm not sure it's the best solution either.

@blueyed
Copy link
Contributor

blueyed commented Nov 21, 2014

See #257 for a PR.

@trinitronx
Copy link

👍 for this feature... People coming from ack seem to expect a portable way to use their .ackrc with ag, or at least modify & adapt their existing one for use with ag. Aliases are ok for setting default arguments like alias ag='ag --pager="less -SMFRX"', but things can get unwieldy pretty quick if you have a lot of arguments you want to add. I can see that implementing this in a way that has to parse the file would be not very fast and would make it harder to maintain.

Perhaps the implementation could be quick and dirty: simply check for an ~/.agrc file, then if it exists read it and append the lines found to the argv array, then continue as normal. This would let parse_options(argc, argv, &base_paths, &paths); do all the hard work, makes it easier to maintain and allows for future-proof support for other options added later. If the ~/.agrc file doesn't exist, then skip the whole code branch to read it in for speed.

@diego898
Copy link

I'd just like to say this would be very useful for me. Its a shame that the only way to do this is with aliases.

@Cxarli
Copy link

Cxarli commented Dec 17, 2018

I'd like to bump this. I'm surprised that such an awesome package doesn't already feature something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants