-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support persistent configuration (.rgrc
?)
#196
Comments
Can you make do with creating an alias? Or even a script in your
|
I just updated the OP with alias stuff 😄 And yes, I could, but then I have to remember my aliases (woe is me, right?). Doing
|
Why don't you just alias
Then you can do (Also, |
Aliasing rg seems pretty good! I can provide a PR for zsh type (just add an entry here I suppose: https://github.com/BurntSushi/ripgrep/blob/master/src/types.rs) But I'd still really like for that to be defined for rg, and not drowned amongst all of my other aliases (I still do |
Sounds good!
You can also do |
Conclusion: I can achieve what I want using simple aliases. I'd still like an |
Or maybe support |
I do feel like aliases are a pretty good solution to this problem, and I'd like to stick with them for now. I think we should leave this ticket open so that others can chime in. For example, aliases may not be easy to define on all platforms. |
BTW, is it possible to not recurse through directories? Case in point is searching for something in a zsh file in Additionally: Is it possible to add ignore patterns? I managed to hit chrome application cache, which is an absolutely monstrous file |
Yes:
Yes. Create a |
Ok, but not add ignore to the execution itself? Will an |
I don't understand the question.
Please use
I don't understand what's confusing about it. The Silver Searcher supports the same format. The |
Perhaps you're looking for the |
I want to do e.g.
Nowhere, it was just a name proposal. I can guess you don't like it though 😁
That should work! Just BTW, using
Doing |
You probably want
Seems correct to me. Read the docs again please:
A value of zero only searches the starting points. So if you run |
Ah of course, so Thanks for answering all of my questions, super helpful! 😄 Especially the |
It's most likely that a value of |
A more useful thing for |
I've hit one issue with using an alias: zsh completion doesn't work when I've shadowed the EDIT: The answer is |
Just my two cents, but I really like .ackrc because it's used at the command line and when invoked by other tools like Emacs (a place that aliases don't work). |
In that case, can you put a wrapper script in your $HOME/bin? On Nov 23, 2016 00:08, "Ivan Andrus" [email protected] wrote:
|
I know of at least one Windows user who wants this pretty badly. (cc @retep998) It sounds like the claim is that, on Windows at least, defining aliases and/or wrapper scripts is neither common nor convenient to do. Is this others' experience as well? Could someone please outline exactly what one has to do on Windows to create a wrapper script? Is it really an unreasonable expectation? If we go down this path, we should consider the following:
IMO, the above implies significant complexity and likely an easy source of bugs. If we moved forward with this, I think I'd have to demand a rock solid specification (which I'm not inclined to work on any time soon) or some kind of conscious concessions at least (like, "not every option is overridable," for example, which seems like bad UX honestly). |
@kbknapp TL;DR I think any specific issues with
I think I can just do this already? [EDIT] - Ah I see, you're talking about one big string that clap then parses. Yeah that'd be interesting.
I've got this worked out now. :-) See 90387bb and in particular the I should revise what I just said. I have it worked out for ripgrep. I suspect solving this in a general case is far harder and there are probably lots of variants. I don't envy your task! To be honest though, I'm actually pretty happy with my work-around thus far. It caused me to clean up my arg definitions, and the changes to the code that interfaces with
Interesting! ack has this feature AFAIK. Best to start without it then. :-)
Ah yeah I should have said more words. The
Yup, good point. Drats. That kind of deflates that idea then!
Yeah I think that is consistent with Ack but actually inconsistent with @kbknapp's thoughts above! Regardless, it seems wise to punt on the auto-loading aspect of this ticket for now anyway. If project specific configs are contentious (and you make a good point), then the other variant of autoloading is to look in platform specific directories where application configs are normally stored, and as far as I can tell, the Rust ecosystem doesn't offer anything in that space that I'd be comfortable using just yet. |
@nagisa on IRC suggested an env var that could be used to specify the location of a config file. It's slightly roundabout, but I think would be a nice sweet spot. It would sidestep the Windows issue of needing to write an alias/wrapper script, and also sidestep the issue of needing to parse an argv out of an env var itself. |
(Hah, if we support a Maybe only the env var for now? ^_^ |
To be clear, I'm not stuck in a position either way, those were just my initial thoughts. The only thing I have strong fieelings about is CLI should override all, which it sounds like is a universa thought 😉 |
Yes indeed! |
Some thoughts/comments:
|
@BatmanAoD Sounds great! When I did my survey on available crates, I basically dismissed almost all of them a priori without even looking at the code based on one (or more) of the following reasons:
So on those grounds they basically all failed the sniff test before I was willing to spend more time with them. So in that sense, I don't know if any were a good start. You'll need to do your own review. :-) If you do take this on, beware the can of worms. Here are some relevant links:
|
Definitely. This will be in the initial support for persistent config. |
If you want to add support for I mean if I have a |
@wsdjeg Please see comments above. I think we're going to punt on everything for now except for setting the config file path via an env var. |
oh, sorry, use |
This commit adds support for reading configuration files that change ripgrep's default behavior. The format of the configuration file is an "rc" style and is very simple. It is defined by two rules: 1. Every line is a shell argument, after trimming ASCII whitespace. 2. Lines starting with '#' (optionally preceded by any amount of ASCII whitespace) are ignored. ripgrep will look for a single configuration file if and only if the RIPGREP_CONFIG_PATH environment variable is set and is non-empty. ripgrep will parse shell arguments from this file on startup and will behave as if the arguments in this file were prepended to any explicit arguments given to ripgrep on the command line. For example, if your ripgreprc file contained a single line: --smart-case then the following command RIPGREP_CONFIG_PATH=wherever/.ripgreprc rg foo would behave identically to the following command rg --smart-case foo This commit also adds a new flag, --no-config, that when present will suppress any and all support for configuration. This includes any future support for auto-loading configuration files from pre-determined paths (which this commit does not add). Conflicts between configuration files and explicit arguments are handled exactly like conflicts in the same command line invocation. That is, this command: RIPGREP_CONFIG_PATH=wherever/.ripgreprc rg foo --case-sensitive is exactly equivalent to rg --smart-case foo --case-sensitive in which case, the --case-sensitive flag would override the --smart-case flag. Closes #196
PR submitted: #772 |
I was going to ask what the eventual behavior was decided, but you wrote it up quite well in the commit message (a very helpful example of a good commit msg btw):
|
Awesome! thanks! When are you planning to create a new release? |
@elentok Soon. Releases happen when they happen. I do this in my spare time, so I will never set an explicit schedule. |
I was re-reading through old messages in this thread and noticed the Assuming these are equivalent:
Since clap allows combining short switches (i.e. Since ripgrep has quite a few short switches, I'd says it's possible (not sure how likely) a combination of short switches would also equal a long flag sans The fix for this would be to document, IF the user intends to combine switches in a ripgrep config, they should add a leading Just some thoughts 😄 |
@kbknapp Interesting. Good thing I did not implement that shortcut. Sounds like a good reason to just not do it! |
I think i had in mind (a) only one option per line and/or (b) not even supporting the short options, since (i believe) that's how the other tools i mentioned work. But yeah you couldn't omit the |
I know I'm late to the discussion, especially since you've (@BurntSushi) already submitted a PR, but I do like how |
@danemacmillan I'm happy with the approach I took. |
Not only that, but the PR has been merged and is in the 0.8.0 release! |
I'd love to keep different types for instance, and not have to specify
--type-add
each time.My specific case is type zsh which searches zsh config files (
.zshrc
*.zsh
, and some custom.zsh*
).Maybe it could support more stuff like
no-heading
,--heading
etc as well, which would allow people to customize rg more.(I know I can just
alias rgzsh="rg --type-add 'zsh:*.zsh' --type-add 'zsh:.zshrc' --type zsh"
, but meh)Loving the tool, btw!
The text was updated successfully, but these errors were encountered: