Closed sartak closed 2 years ago
Hi Shawn, thanks for being interested in contributing. To be honest, this is a really tough feature to add for various reasons. See my previous thoughts on it here. https://github.com/PatrickF1/fzf.fish/pull/118#issuecomment-780738223
Even if we implement this exactly the way I specified in the comment, I'm still not sure I would merge it.
That's unfortunate :/ Thanks again for fzf.fish.
Sorry about the wasted time spent on this. And thanks for being a good sport and understanding!
It’s all good! Most of the time was spent on the implementation, which I can still keep for myself :)
If you change your mind please let me know and I can polish this up for inclusion.
This PR adds a new kind of search: grep directory. It's similar to "search directory" but instead of fuzzy-matching file names, grep directory does regex-matching on file content, powered by
rg
. The default hotkey is ctrl-g.Here's what it looks like, and one example of why I think it's cool.
There's a few minor shortcomings that I left out for now to avoid complicating the code. If you think this feature is worthy of inclusion, I'd be happy to give any or all of these a shot!
rg
, and so there's no way to switch toag
, orgrep -r
.rg
as the initial regex. We could be a little more nuanced. fzf.fish's directory search checks if the input ends with a slash and is a directory, and if so, sets that as the base directory forfzf
's input. I think that'd be a good fit here too.rg
with no regular expression shows a list of empty results. We can probably do something better than that, but I'm not sure what. (Maybe default to showing all lines when user input is empty, to better match the "filtering" affordance)--highlight-line {2}
from_fzf_grep_directory
intobat
. The blocker here is_fzf_preview_file
's comment of "we collect all the arguments into one single [path] variable". (I temporarily hacked in support for highlighting the matching line in the preview video above, but it's not shippable.)Anyway, thanks for fzf.fish! Let me know if there's anything you'd like me to improve on here.