rupa / z

z - jump around
Do What The F*ck You Want To Public License
16.36k stars 1.17k forks source link

Fuzzy Search #111

Open btc opened 11 years ago

btc commented 11 years ago

Hi. First off, thanks for creating this script. It's fantastic.

How would you feel about augmenting the string matching to perform a fuzzy search? Would you consider merging such a feature upstream?

btc commented 11 years ago

For example:

z sectlr

would match

/src/server/search_controller
tyilo commented 11 years ago

Would z foobar match /foo1/bar2 or just /path/foo1bar2 ?

btc commented 11 years ago

It would match foo1bar first. This choice is just 1 char away from a perfect substring match. foo1/bar is 2 chars from a substring match.

rupa commented 11 years ago

I'm not super into that sort of fuzzy matching. I like having each argument be a regex, and I'm not sure i'd like some combination of the two. It's tempting to try falling back to this sort of matching if regex doesn't turn up any results, but I wonder if that would increase the frequency of ending up in a dir i didn't expect, which is more irritating to me than nothing happening.

What I have been considering for a while is forcing the arguments to be in order. With that, something like z s e c t l r would do what you envision, albeit rather tediously. It would simplify some of the code too. I'll probably push a branch with that and see how it feels for a while.

rupa commented 11 years ago

FWIW, pushed 'ordered_args' branch.

btc commented 11 years ago

Cool. I'll try it out.

tpounds commented 8 years ago

I like the idea of fuzzy search but I'm not sure which method I would prefer. I thought about patching my local version of z to support fuzzy search using phonetic matching (e.g. soundex, metaphone) for each component in the path. This would allow matching of paths supporting variation in case or when I make a simple typo. Matching priority order could be exact, regex, and phonetic.

mrjohannchang commented 7 years ago

Check this out: fz.

ghost commented 7 years ago

I'd prefer fuzzy search to the current default.

Same with v, I think fuzzy search would be a better option there too.