by mgunyho · 4y ago · 0 comments
While digging up alternatives (of course after I had already written most of the functionality), I briefly tried out fzf. I think at that time I couldn't find an example snippet like yours to do the cding, so I didn't look into it much more. With some basic settings, it was also not easy (or even possible?) to go up in the folder tree, but I see that your example handles that.
If you're unfamiliar with a big folder tree, fzf (or another very similar tool that is designed for this purpose, broot) can be more efficient. But it might take a while for it to scan all subfolders.
Well, fzf is only a selection tool, it's more about the tool that feeds fzf data ;) That's why I used a dumb ls in my example. Maybe a difference with yours is that it does perform cd on each loop, and there's no way to bail out and not cd.
> it might take a while for it to scan all subfolders.
Haha yeah, for recursive cases I was using ripgrep as fzf default command:
rg --files --no-ignore --hidden --follow --glob "!{.git,node_modules}/*" | fzf
And now I just discovered fd[0]: fd --no-ignore --hidden --follow --strip-cwd-prefix | fzf
(...at least essentially, my setup is a bit more tunable and complex, I have a few of these with varying flags depending on the situation and goal)