agkozak / zsh-z

Jump quickly to directories that you have visited "frecently." A native Zsh port of z.sh with added features.
MIT License
1.93k stars 77 forks source link

Getting error when trying autocomplete #91

Open jamnaughty opened 3 weeks ago

jamnaughty commented 3 weeks ago

I am getting an error when trying z .

(eval):1: command not found: _zshz (eval):1: command not found: _zshz

I have tried removing zsh completion cache but it is not working. Also tried this command compdef _zshz ${ZSHZ_CMD:-${_Z_CMD:-z}} and still, the problem persists.

agkozak commented 3 weeks ago

Could you share your .zshrc with me? Just copy and paste it here. Thanks!

agkozak commented 3 weeks ago

Also, check in the directory where Zsh-z is installed to make sure that the file _zshz is actually there.

jamnaughty commented 3 weeks ago

Thanks, it seems the _zshz is missing in the Oh-my-zsh repo. I cloned a brand new one and it is missing there. After I copied _zshz from this repo, things are working again.

agkozak commented 3 weeks ago

Do go ahead and post your .zshrc. In Oh-My-Zsh, the file is _z, but it's the same function and it should all work. I'd like to make sure that we identify what is going wrong.

jamnaughty commented 3 weeks ago

Here you go. https://gist.github.com/jamnaughty/8c58313cd801f5e59d0161427ab9f39b

agkozak commented 3 weeks ago

I haven't been able to find what's causing your problem, but of course your .zshrc is loading things that I can't see. Out of curiosity, is there any reason that you source both Oh-My-Zsh and znap?

Try typing at the command line

setopt

and let me know what it says. That might give me some insight. Thanks!

jamnaughty commented 3 weeks ago

znap is left over from the experiment I was doing to try to start zsh faster. :-)

alwaystoend autocd autopushd combiningchars completeinword extendedhistory noflowcontrol histexpiredupsfirst histignoredups histignorespace histverify interactive interactivecomments login longlistjobs monitor promptsubst pushdignoredups pushdminus sharehistory shinstdin zle

agkozak commented 3 weeks ago

Hmm...I'm still not seeing the problem. Let's make sure your fpath is correct. Could you type

print -l $fpath

and tell me what you see? Thanks.

jamnaughty commented 3 weeks ago

/Users/dhiman/.zsh/zsh-snap/completions /Users/dhiman/.local/share/zsh/site-functions /Users/dhiman/.autoloaded /Users/dhiman/.oh-my-zsh/custom/plugins/fzf-zsh-plugin/completions /Users/dhiman/.oh-my-zsh/custom/plugins/fzf-zsh-plugin /Users/dhiman/.oh-my-zsh/plugins/extract /Users/dhiman/.oh-my-zsh/plugins/colored-man-pages /Users/dhiman/.oh-my-zsh/plugins/z /Users/dhiman/.oh-my-zsh/plugins/git /Users/dhiman/.oh-my-zsh/plugins/history-substring-search /Users/dhiman/.oh-my-zsh/functions /Users/dhiman/.oh-my-zsh/completions /Users/dhiman/.oh-my-zsh/cache/completions /opt/homebrew/share/zsh/site-functions /opt/homebrew/share/zsh-completions /usr/local/share/zsh/site-functions /opt/homebrew/Cellar/zsh/5.9/share/zsh/functions

agkozak commented 3 weeks ago

That looks fine.

There's something going on on your system that I don't have any insight into; I can load your .zshrc on one of my own computers, and z completions work perfectly.

Could you back up your .zshrc and replace it with the minimal

export ZSH="$HOME/.oh-my-zsh"
plugins+=(z)
source $ZSH/oh-my-zsh.sh

Then type

exec zsh

and try using z, including tab completions. If that fixes your problem, we'll have an idea of what to do moving forward.

In the long term, by the way, I strongly suggest running either Oh-My-Zsh or znap, but not both. Using both introduces unnecessary complexity.

jamnaughty commented 3 weeks ago

That worked for me now.

agkozak commented 3 weeks ago

OK, I think what you should do is to restore your original .zshrc and then comment out parts of it until z tab completion works. Perhaps at first keep everything including loading oh-my-zsh.sh but exclude the parts with znap? At some point you'll probably find that there's an individual line that breaks tab completion. Once you find out what that is, we can talk about a workaround.