ajeetdsouza / zoxide

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

zi no longer uses fzf for completion #626

Open hrouault opened 1 year ago

hrouault commented 1 year ago

It has been one or two months that zi no longer completes using fzf.

I installed zoxide (version 0.9.2) with cargo, and fzf was installed through homebrew (version 0.42.0 by homebrew on OSX).

zoxide is configured with "zoxide init fish | source".

Do you have any suggestions on how to debug this? I've tried to use the query command, which also does not use fzf.

Thanks

vimkim commented 1 year ago

This is exactly what I was curious about.

I'm using powershell 7 in Windows 11.

I upgraded winget, delete zoxide 0.9.2 and reinstalled both winget and choco version zoxide, uninstalled fzf v0.42 and force reinstalled and I could not make the fuzzy match work when using zi.

Fzf has no problem when used directly.

My profile.ps1 looks like this, which is a typical setting for a powershell user I guess.

Invoke-Expression (& {
        $hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
    (zoxide init --hook $hook powershell | Out-String)
    })
amsam0 commented 1 year ago

I am also noticing this. fzf is on PATH but zi does not appear to use it. It would also be nice if z used fzf for matching.

ohai89 commented 1 year ago

Zoxide 0.9.1 changed how fn get_fzf() uses args. (query.rs:76) That update added Search mode --exact which to me seems to be the culprit here. --exact means just that, exact match for fzf search, not a fuzzy one.

I don't know if that was done to fix some other functionality, I am not well-versed in Rust. But with a quick test commenting that argument out, and rebuilding the package with cargo the omit of that flag returns fuzzy matching.

amsam0 commented 1 year ago

It was done to fix #514. I think a better fix would be to use fuzzy finding to match the directories, then rank them.

For now, you can set the _ZO_FZF_OPTS environment variable to --scheme=path --tiebreak=end,chunk,index --bind=ctrl-z:ignore,btab:up,tab:down --cycle --keep-right --border=sharp --height=45% --info=inline --layout=reverse --tabstop=1 --exit-0 --select-1 to revert to the old behavior.

ajeetdsouza commented 1 year ago

I've tried to use the query command, which also does not use fzf.

Hey @hrouault, you can use zoxide query -i to open up fzf. (This is just for debugging, it will not change your current directory).

To help me understand this issue better, could someone share a screenshot of the kind of queries you are making that rely on fuzzy search?

fleimgruber commented 1 year ago

I tried zoxide query -i with de<TAB> as argument for getting at .\dev\my-favorite-project, but only regular PowerShell completion is triggered.

Edit: after reading and thinking a bit more, I now see completion candidates. Please ignore my comment.

ohai89 commented 1 year ago

Hi @ajeetdsouza, please find an example query with fuzzy search active below. fuzzy_search_example Essentially I have a bunch of folders with same kind of names: project-language With fuzzy search I can land on netops-python with query ntp and netops-go with ntg. Without fuzzy search I'd have to write out the path more fully. (mind that this is the output of latest zoxide version with the --exact commented out, and rebuilt via crate)

Yes, without exact search I could get to both folders by querying python or go directly, but in my mind I associate the project name quite heavily to be a part of the query, and tend to begin by writing that out.

In any case I have grown accustomed to fuzzy searching since I can't be bothered to write out the full name of folders most of the time :)

michaelbeaumont commented 1 year ago

To help me understand this issue better, could someone share a screenshot of the kind of queries you are making that rely on fuzzy search?

Is a screenshot necessary?

If I have a directory /../../work in my list and I type zi<ENTER>wrk, my /../../work directory isn't in fzf's results list. It seems blatantly more useful for my /../../work directory to be in the list.

Maybe I'm fundamentally misunderstanding what zoxide is for (or I haven't configured it properly?) for this not to clearly be a very breaking bug. For that matter I'm at a loss to understand why supporting fuzzy search isn't part of the main z command but that's another issue.

Ultimately some directory paths are mentally easier to "type quickly" using letters that aren't a prefix of one of the path elements.

amsam0 commented 1 year ago

I agree, fuzzy finding on the main z command (in addition to zi) would be incredibly useful

den-is commented 6 months ago

Any updates on this thread? I'm not using zoxide interactive but only usual z in shell. Similar issues mentioned in my original issue https://github.com/ajeetdsouza/zoxide/issues/638 sometime "make me" to switch back to autojump. imho docs vs doc and other examples are annoying, time to time I have "to think" and "type query precisely" 🙃