Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Prefer exact matches #49

Open
zachriggle opened this issue Aug 3, 2021 · 2 comments
Open

Feature: Prefer exact matches #49

zachriggle opened this issue Aug 3, 2021 · 2 comments
Assignees

Comments

@zachriggle
Copy link

As always, thank you @agkozak for making the pure-Zsh port of Z.

One of the things I tend to butt up against that is that the "frecency" prefers top matches over exact matches.

This might be something to hide behind a non-default environment variable setting, but currently I have:

$ env | grep ZSHZ
ZSHZ_CASE=smart
ZSHZ_NO_RESOLVE_SYMLINKS=1

$ zshz -l git | tail -3
746426     /Users/zachriggle/github.com/git
1327925    /Users/zachriggle/github.com/zsh
2103788    /Users/zachriggle/github.com/shellcheck

$ zshz -e git
/Users/zachriggle/github.com/shellcheck

And if I do z git it will go to the shellcheck directory. Since git has an EXACT match, I'd kind of prefer that it went there instead. I dug into the code for zsh-z but, despite thinking I know how to Zsh pretty well, can't figure out how or where to add this.

I was hoping that ZSHZ_UNCOMMON would fix this, but it has different (but understandable) behavior.

$ ZSHZ_UNCOMMON=1 zshz -e git
/Users/zachriggle/github.com

It would be nice if there was an e.g. ZSHZ_PREFER_EXACT_MATCHES setting that would... prefer exact matches.

@agkozak
Copy link
Owner

agkozak commented Aug 3, 2021

Thanks so much for the kind words!

I'll put some thought into this.

@agkozak agkozak self-assigned this Aug 8, 2021
@nunzioc
Copy link

nunzioc commented Sep 28, 2021

I think this option would be great to have but for now, you can always force an exact match by using slashes. So in this case, "z /git/" would give the correct result. In a way, this is just obvious behavior of the matching algorithm, but I thought I'd mention it here for others since it took me about a month before I noticed this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants