5 ms·
So I might aswell ask here: I want to search for a string using ripgrep, select one of the files from the result list using FZF and then open the selected file
by Yoofie 4y ago
So I might aswell ask here: I want to search for a string using ripgrep, select one of the files from the result list using FZF and then open the selected file with VS code.
> rg . | fzf
How do I do this on windows (NOT Linux)??
*Note:* Assume I already have ripgrep, FZF & VS Code installed.
- thunderbong 4y agoThe exact same command worked for me on Windows in PowerShell! In fact, I went and tried the other shortcuts and they worked as well e.g. Alt+C Didn't know about this all this while and I had fzf installed!
- Joker_vD 4y agoYou open Total Commander in that folder, press Alt+F7, put your string into the lower search box and press search. It will give you the list of matching files, with F3 available for quick preview; then you right click the file you need and choose "Open with VS Code" from the context menu. Sadly, you don't get the "context" (the content of actual matches) out of the box, you'll have to resort to double-tapping F3 while manually going down the file list. That's a downside, I fully admit that.
- Yoofie 4y agoI appreciate your answer but the whole point is to do everything from the command line. If I need to use another application, I can just open VS Code in the directory and search from there directly. In the article, they provide this: >rg . | fzf | cut -d ":" -f 1 What would be the easy windows equivalent of > cut -d ":" -f 1 ??
- spapas82 4y agocut is a part of git for windows. It should be inside "c:\Program Files\Git\usr\bin\" folder. So after adding this folder to your path `rg . | fzf | cut -d ":" -f 1` should work. However I wasn't able to actually use that to open that file in vscode or vim because the application started immediately without waiting to pick a file ...
- BeetleB 4y agoI use orthodox file managers heavily (mc, FAR, etc). Your approach was my norm for over 20 years. However, fzf is the first tool I've found that far exceeds the file managers in speed of navigation.
- BeetleB 4y agoUse xonsh in Windows (seriously!) https://xon.sh/ https://xon.sh/
- peterstensmyr 4y agoSomething very close to this example is in the fzf “advanced” documentation at https://github.com/junegunn/fzf/blob/master/ADVANCED.md#using-fzf-as-interactive-ripgrep-launcher https://github.com/junegunn/fzf/blob/master/ADVANCED.md#usin...