Comments (24)
No. The ignore code and the glob code are related but distinct. Sorry.
Refactoring the ignore code is pretty high on my list because I hope to get perf gains out of it.
I just got married. I'll get to this when I can.
from ripgrep.
Hmm. Would you be opposed to this going in $XDG_CONFIG_HOME/ripgrep/ignore
? That way, we won't need to specify any weird interaction between the current semantics, which are "obeys parent directory .ignore
files," and the new semantics, which if we did what you suggested would be, "obeys parent directory unless $HOME/.ignore exists, in which case, it's used everywhere." $XDG_CONFIG_HOME
feels a bit more right.
from ripgrep.
Yes. The terminology I'd like to use is "precedence." That is, ignore files specified via --ignore-file have a lower precedence than any other ignore file. That means a whitelisted pattern in an ignore file in a directory will override an ignore pattern in an --ignore-file.
from ripgrep.
Fixed in #202.
from ripgrep.
Sorry, by $XDG_CONFIG_HOME
, I meant "follow the XDG basedir spec." Specifically, if XDG_CONFIG_HOME
isn't set, then it defaults to $HOME/.config
.
from ripgrep.
Well, $HOME/.config/ripgrep/ignore
functionality doesn't exist. I was proposing it and asking if it would satisfy your use case. :-)
from ripgrep.
I am on RHEL6.6 and echo $XDG_CONFIG_HOME
returns
XDG_CONFIG_HOME: Undefined variable.
Also this is work machine.. so I don't have admin rights. Do we have an xdg alternative in that case?
from ripgrep.
Hmm, I symlinked $HOME/.config/ripgrep/ignore
to ~/.agignore
. I also tried few other symlink names. But none helped.. The files ignored in ~.agignore
are still being searched.
km²~/.config/:ripgrep> lta
total 8.0K
drwxr-xr-x 28 kmodi users 4.0K Sep 24 00:48 ../
lrwxrwxrwx 1 kmodi users 21 Sep 24 00:52 .rpignore -> /home/kmodi/.agignore
lrwxrwxrwx 1 kmodi users 21 Sep 24 00:52 .ignore -> /home/kmodi/.agignore
lrwxrwxrwx 1 kmodi users 21 Sep 24 00:52 ignore -> /home/kmodi/.agignore
drwxr-xr-x 2 kmodi users 4.0K Sep 24 00:52 ./
km²~/.config/:ripgrep> pwd
/home/kmodi/.config/ripgrep
km²~/.config/:ripgrep>
from ripgrep.
Ah OK, that would work as long as I can maintain just one common global ignore file :)
Thanks!
from ripgrep.
Here's another idea to implement the same. I like it better because then I use an alias to have the complete rg
configuration control.
How about having a switch named --ignore-file
. Here's a spec suggestion for that:
--ignore-file FILE: Read the
.ignore
file FILE before reading the.ignore
,.gitignore
, etc. in the current or parent directories. Multiple--ignore-file
flags may be used.
from ripgrep.
When you say "Read the ignore file before reading .ignore .gitignore in current or parent directories," do you mean that --ignore-file
takes precedence over them? (In contrast, I'd expect .ignore
/.gitignore
to take precedence over a global config file.)
from ripgrep.
do you mean that --ignore-file takes precedence over them?
No, here was my thinking..
Let's use we did rg --ignore-file ~/.ignore foo
and suppose we had:
$ cat ~/.ignore
*.log
Suppose we had a /proj
and
$ cat /proj/.ignore
!imp.log
Then if ~/.ignore
(FILE arg to --ignore-file
) is read first, /proj/.ignore
will be able to white-list some part out of the ignore set by the previously read file if we are running rg --ignore-file ~/.ignore foo
from the /proj
directory.
So, read first implies open to be overridden.
from ripgrep.
@kaushalmodi Hmm, yes, I see, I think those semantics makes sense.
from ripgrep.
FWIW the_silver_searcher uses --path-to-ignore SOMEPATH
and the file name used is (as of 0.33.0) .ignore
from ripgrep.
Allowing multiple --ignore-file
becomes even more useful as I see an application where I can have a central .ignore
file for the whole project (version controlled), and then users can add their specific .ignore
files on top of that if they wish.
from ripgrep.
@kaushalmodi I definitely like the idea of --ignore-file
(allowing multiple uses) better than a global ignore file. If we just add that, does that satisfy your use case?
from ripgrep.
If we just add that, does that satisfy your use case?
Absolutely! Then I need to simply add that to my alias and then it becomes as good as a global ignore file. What's even better is that I can have more than one global ignores.. one that is central to the whole project, others which could be user-specific.
from ripgrep.
Perfect. Much easier to implement. Hopefully tonight. :-)
from ripgrep.
Thanks! Just to confirm that they will have the lowest priority when compared with the ones in the current/parent directories as in my example above, correct?
from ripgrep.
This is slightly trickier than I thought and probably exceeds my budget for middle-of-the-week work unfortunately. The issue is that every ignore file needs to interpret paths relative to itself (these are the semantics of .gitignore
, and frankly, nothing else really makes much sense), and current ignore code makes this a little tricky. I'm happy to hack this in because I have plans to overhaul the ignore code anyway, but it requires a bit more attention than I'm capable of right now.
from ripgrep.
I hope that the overhaul in the globbing code now makes it possible to implement this.
from ripgrep.
I just got married. I'll get to this when I can.
Understood. Congratulations! :)
from ripgrep.
@BurntSushi I think it's unfortunate that there's no way (?) to get the behaviour you proposed but ultimately decided against:
# $XDG_CONFIG_HOME/ripgrep/profile
export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME/ripgrep/ripgreprc"
# ripgreprc
--ignore-file="$XDG_CONFIG_HOME/ripgrep/ignore"
# ignore
*.lock
"$XDG_CONFIG_HOME/ripgrep/ignore": No such file or directory (os error 2)
Would you be open to making something possible here? If so, which issue do I open - 'parse env vars in ripgreprc', or 'revisit global ignore file'? 🙂
NB: another (probably simpler) approach could be to allow relative (to the RIPGREP_CONFIG_PATH
) paths:
./ignore: No such file or directory (os error 2)
(edit: when I say 'no way', I suppose I mean 'with static config files' - obviously I could have my .profile
write out the location to ripgreprc
, or alias
it. It's just the former seems.. not great, and the latter would really need to be a wrapper script on PATH, since I'd also want this in vim for example, so that ends up quite 'hacky' too.)
from ripgrep.
I don't know why you see wrapper scripts as hacky. I have a whole bunch of them in my ~/bin
.
from ripgrep.
Related Issues (20)
- Include valid values in --help HOT 2
- Turn on PCRE2 automatically with a warning when look-around or backreferences are detected HOT 2
- consider adding an `rg:` prefix all error messages HOT 1
- issue when using double quotes to search in linux HOT 1
- feat(globset): allow custom component separator characters? HOT 3
- [ignore] Add API for adding glob patterns to ignore HOT 4
- shard regexes when there are many and do multiple passes over the haystack HOT 4
- Ripgrep significantly slower than grep HOT 3
- Ability to ignore non-existent `PATTERNFILE` HOT 2
- multiline search regex wildcard not expanding HOT 1
- Precompiled binary for powerpc64le HOT 1
- Add Vuejs as a file list to type-list HOT 1
- zero or more quantifier does not work HOT 1
- Inconsistent behavior with negation pattern in `.gitignore` HOT 8
- compiling with simd-accel feature is broken due to removal of stdsimd feature in nightly breaking the packed_simd crate HOT 1
- File named `.config` is ignored for no reason HOT 1
- Process substitution search path behavior change in 14.0.0
- [feature] Line masking (ignoring lines or part of lines in matching but displayed in output) HOT 3
- Provide Statically Compiled Binaries for (aarch64|arm64) Linux HOT 1
- Include regex syntax in man page HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ripgrep.