agkozak/zsh-z

oh-my-zsh: command not found

ibnuh opened this issue · 4 comments

ibnuh commented

I followed this guide from the readme and got the following messages
https://github.com/agkozak/zsh-z#for-oh-my-zsh-users

/home/ibnuh/.oh-my-zsh/custom/plugins/zsh-z/zsh-z.plugin.zsh:61: command not found: ^M
/home/ibnuh/.oh-my-zsh/custom/plugins/zsh-z/zsh-z.plugin.zsh:63: command not found: ^M
/home/ibnuh/.oh-my-zsh/custom/plugins/zsh-z/zsh-z.plugin.zsh:98: parse error near `\^M'

running zsh with latest oh-my-zsh on WSL2 windows
zsh 5.8 (x86_64-ubuntu-linux-gnu)

^M represents a carriage return. Something in your setup is translating Unix-style newlines (linefeeds) into Windows-style newlines (carriage return + linefeed: CRLF).

Try typing

cat ~/.gitconfig

Let me know what you find.

ibnuh commented
> cat ~/.gitconfig

[user]
        email = xx
        name = xx
[core]
        filemode = false
        autocrlf = true
        safecrlf = false

Fixing the file with dos2unix seems to fix it

dos2unix /home/ibnuh/.oh-my-zsh/custom/plugins/zsh-z/zsh-z.plugin.zsh

any suggestion for a permanent solution?

thank you!

I'm pretty sure that your autocrlf setting is the problem. The file on GitHub doesn't have ^M, but your git is adding it. You might try changing autocrlf = true to autocrlf = false and cloning a fresh copy of ZSH-z. Let me know if that works.

ibnuh commented

I prefer to use CRLF for git because I'm on a windows machine, I don't mind converting the file everytime there is an update.

Thanks again!