-
-
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
Add printf-like option for custom formatting of filepaths #2686
Comments
#665 is already done FWIW, and it needed a lot more than a simple 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:
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. |
Thanks for the prompt reply.
Sorry, guess I missed that part. I skimmed the issue and it sounded like you weren't into the proposal.
Sorry for the confusion. I initially had My
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 |
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.
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. |
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 |
When ripgrepping across multiple files, the path to the parent file is shown alongside each match. This is problematic when the filepaths get long. For example, when using absolute filepaths.
A nice addition would therefore be some way to customize the way that paths that are shown.
Probably the most useful example would be to replace whatever
$HOME
expands to with~
. But one can imagine something like adding entries into.ripgreprc
mapping commonly used paths to informative yet shorter strings, e.g.This would ensure that even when ripgrepping using absolute paths, the output won't eat up needless horizontal space. It would also allow users to tailor ripgrep to their bespoke formatting needs, e.g., #665.
The text was updated successfully, but these errors were encountered: