z icon indicating copy to clipboard operation
z copied to clipboard

Fuzzy Search

Open btc opened this issue 11 years ago • 9 comments

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 avatar Aug 17 '13 23:08 btc

For example:

z sectlr

would match

/src/server/search_controller

btc avatar Aug 17 '13 23:08 btc

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

tyilo avatar Aug 17 '13 23:08 tyilo

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.

btc avatar Aug 18 '13 01:08 btc

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 avatar Aug 18 '13 05:08 rupa

FWIW, pushed 'ordered_args' branch.

rupa avatar Aug 18 '13 16:08 rupa

Cool. I'll try it out.

btc avatar Aug 18 '13 20:08 btc

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.

tpounds avatar Nov 23 '15 16:11 tpounds

Check this out: fz.

mrjohannchang avatar Mar 19 '17 20:03 mrjohannchang

I'd prefer fuzzy search to the current default.

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

nodingneu avatar Nov 09 '17 07:11 nodingneu