ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
22.47k stars 546 forks source link

better fault tolerance #132

Closed GopherJ closed 3 years ago

GopherJ commented 3 years ago

I find that I cannot type: test-post to jump to a directory called test-box-postfix, I have to type postfix to be able to jump in, but considering that I don't have any other directories containspost, it looks strange to me that zoxide cannot figured it out. is it possible to have bigger fault tolerance? Let's say even fuzzer

ajeetdsouza commented 3 years ago

z test post should work here. Writing it as test-post makes zoxide look for a single substring, which is why you don't see a match.

We have considered fuzzy matching in the past, but I'm not entirely sold on it. I've found that non-fuzzy matching has three main advantages:

GopherJ commented 3 years ago

@ajeetdsouza Thanks it worked, I agree that jumping to not wanted directory is bad... That's why I switched from autojump-rs to zoxide because things are more predictable like you've said.

However on the same time maybe there is still a small effort to do on zoxide side to make it smarter, like removing special charaters of input and target directory etc.

ajeetdsouza commented 3 years ago

removing special characters of input

That again makes things unpredictable. Why add a special character to the query that you don't want to match against? A space is easier to type anyway.

I think the fuzzy matching you're looking for here somewhat resembles the Smith-Waterman algorithm (looks for similar sequences in the input and output), which is what fzf uses. zoxide works out of the box with fzf using the zi command.

While you can use zi everywhere to cd into directories, it usually takes way more characters for fzf to figure out the correct directory than it takes zoxide. So I'd still suggest something like zi test followed by typing post into the interactive prompt.