ajeetdsouza / zoxide

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

sudden zstyle issues with zoxide 0.9.4 #729

Closed dannysteenman closed 4 months ago

dannysteenman commented 4 months ago

I've installed the latest release (0.9.4) today and suddenly my fzf-preview stopped working for zoxide on the latest macOS.

This is my configuration in .zshrc file:

zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'eza -1lh --icons --git-ignore --group-directories-first --sort=accessed --color=always $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-flags --height=35% --preview-window=right:65%

... <more settings here>

eval "$(zoxide init --cmd cd zsh)"

fzf version: 0.46.1 (brew) macOS 14.3.1 23D60 arm64 zsh 5.9

ajeetdsouza commented 4 months ago

Could you link me to fzf-preview? I'm not familiar with it.

dannysteenman commented 4 months ago

Could you link me to fzf-preview? I'm not familiar with it.

Sure! it's part of fzf-tab, see docs: https://github.com/Aloxaf/fzf-tab/wiki/Preview

ajeetdsouza commented 4 months ago

That's because cd is no longer an alias of __zoxide_z. Try directly enabling it for cd:

zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1lh --icons --git-ignore --group-directories-first --sort=accessed --color=always $realpath'
zstyle ':fzf-tab:complete:cd:*' fzf-flags --height=35% --preview-window=right:65%
dannysteenman commented 4 months ago

@ajeetdsouza that worked, thank you!

Since you mentioned that cd is no longer an alias, I got some issues with cd when using for example znap (https://github.com/marlonrichert/zsh-snap).

when I run znap pull or znap status, zoxide is giving error messages which didn't occur in the previous version of zoxide 0.9.3.

error:

❯ which cd
cd () {
    __zoxide_z "$@"
}
❯ znap status
Aloxaf/fzf-tab zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
✓
junegunn/fzf ✓
paulirish/git-open fatal: not a git repository (or any of the parent directories): .git
✓
romkatv/powerlevel10k ✓
zdharma-continuum/fast-syntax-highlighting ✓
zsh-snap ✓
zsh-users/zsh-autosuggestions ✓
zsh-users/zsh-completions ✓
zsh-users/zsh-history-substring-search ✓

source of the znap status command which uses the cd command: https://github.com/marlonrichert/zsh-snap/blob/755566ca73bfe3cc229fe90fcc0ba87d58325771/functions/.znap.status#L26

Example of how I currently configured zoxide in my .zshrc:

eval "$(zoxide init --cmd cd zsh)"

What seems to solve the issue for now is if I initialize zoxide without the --cmd cd argument and then create an alias for z to cd:

alias cd=z
alias cdi=zi

Then znap status works again:

❯ which cd
cd: aliased to z
❯ znap status
Aloxaf/fzf-tab v1.0 ✓
junegunn/fzf ✓
paulirish/git-open ✓
romkatv/powerlevel10k ✓
zdharma-continuum/fast-syntax-highlighting ✓
zsh-snap ✓
zsh-users/zsh-autosuggestions ✓
zsh-users/zsh-completions ✓
zsh-users/zsh-history-substring-search ✓
ajeetdsouza commented 4 months ago

There isn't much we can do from our end to prevent this - cd has been overridden, and znap is calling the overridden cd command.

I've created a PR on znap's repo to fix the way they call cd, which should fix the issue: https://github.com/marlonrichert/zsh-snap/pull/277