Comments (4)
#665 is already done FWIW, and it needed a lot more than a simple printf
option like you're asking for here. Actually, I'm not sure exactly what you're asking for here. The issue title mentions printf
, but your actual request seems to suggest wanting something that permits hard-coding paths to replace with shorter strings.
With all that said, I do think you made the specific problem you care about pretty clear, but I think there's already a pretty standard solution to that:
$ rg is_accel /home/andrew/rust/ripgrep/
/home/andrew/rust/ripgrep/crates/regex/src/literal.rs
73: if re.is_accelerated() {
$ (cd /home/andrew/rust/ripgrep && rg is_accel)
crates/regex/src/literal.rs
73: if re.is_accelerated() {
That is, ripgrep already lets you shorten the file paths it prints. You just need to change ripgrep's current working directory and provide a relative path.
from ripgrep.
Thanks for the prompt reply.
#665 is already done FWIW
Sorry, guess I missed that part. I skimmed the issue and it sounded like you weren't into the proposal.
Actually, I'm not sure exactly what you're asking for here. The issue title mentions
printf
, but your actual request seems to suggest wanting something that permits hard-coding paths to replace with shorter strings.
Sorry for the confusion. I initially had find
's -printf
option in mind when I drafted the title, which can do exactly what I said but also so much more. After drafting the body I debated changing the title too, but just rolled with it.
My .ripgreprc
proposal does involve hardcoding paths, but I left the door open to other ideas in case there was a more elegant solution.
ripgrep already lets you shorten the file paths it prints. You just need to change ripgrep's current working directory and provide a relative path.
With unix tools, there is almost always a way. However, this approach will only work if you are executing ripgrep directly.
But what about if it runs inside a function that gets executed by keybinding? For example, this amazing fzf + ripgrep example, which I have a couple variants of mapped to different keybindings.
That is just one specific example, but emblematic of a more general use case that would be solved by a dedicated argument or behavior configurable in .ripgreprc
.
from ripgrep.
There's still a way even then if you feel strongly enough. You can use symlinks to shorten a path. Not the prettiest answer and has downsides of its own, but it's there if you really need it.
find
's printf flag is an enormous surface area. I'm not too keen on adding that.
I think for fzf, it would make more sense for the thing doing the display to try to trim down the output when possible.
I understand the request, but this is the kind of scope increase that I'd prefer not to chase. It also doesn't help that this is exactly the kind of thing that begets more features. As soon as something like this added, folks are going to want to customize it in more ways. It's too heavy of a maintenance burden and the benefit isn't big enough to justify it IMO.
from ripgrep.
Makes sense! Not the outcome I was hoping for but your justifications are totally reasonable. Thanks anyway for discussing it!
Should you ever change your mind, something similar is being considered for fd
that perhaps you could check out for inspiration (see sharkdp/fd#533 and sharkdp/fd#1043). Admittedly this functionality is less out of scope for fd
than ripgrep
, but anyway, it's a precedent 😄
from ripgrep.
Related Issues (20)
- Inline flag (?x) with comment doesn't work due to automatic wrapping of patterns inside non-capturing group HOT 1
- Add Completion Files + Manpage to Source Repository HOT 3
- Multiline fixed string search failing when a newline character is followed by the ^ character HOT 10
- darcs boringfiles HOT 1
- Memory not freed in ignore crate when ignore flags are enabled HOT 1
- 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
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.