我正在尝试在Ubuntu 15上安装oh-my-zsh。运行安装脚本后
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Run Code Online (Sandbox Code Playgroud)
我有以下从未发生过的错误
/home/li-xinyang/.zshrc:3: command not found: ^M
/home/li-xinyang/.zshrc:9: command not found: ^M
/home/li-xinyang/.zshrc:12: command not found: ^M
/home/li-xinyang/.zshrc:16: command not found: ^M
/home/li-xinyang/.zshrc:19: command not found: ^M
/home/li-xinyang/.zshrc:22: command not found: ^M
/home/li-xinyang/.zshrc:25: command not found: ^M
/home/li-xinyang/.zshrc:28: command not found: ^M
/home/li-xinyang/.zshrc:31: command not found: ^M
/home/li-xinyang/.zshrc:34: command not found: ^M
/home/li-xinyang/.zshrc:39: command not found: ^M
/home/li-xinyang/.zshrc:44: command not found: ^M
/home/li-xinyang/.zshrc:47: command not found: ^M
/home/li-xinyang/.zshrc:52: command not found: ^M
/home/li-xinyang/.zshrc:53: command not found: ^M
/home/li-xinyang/.zshrc:55: command not found: ^M
/home/li-xinyang/.zshrc:58: command not found: ^M
/home/li-xinyang/.zshrc:source:59: no such file or directory: /home/li-xinyang/.oh-my-zsh/oh-my-zsh.sh^M
/home/li-xinyang/.zshrc:60: command not found: ^M
/home/li-xinyang/.zshrc:63: command not found: ^M
/home/li-xinyang/.zshrc:70: command not found: ^M
/home/li-xinyang/.zshrc:73: command not found: ^M
/home/li-xinyang/.zshrc:76: command not found: ^M
Run Code Online (Sandbox Code Playgroud)
如何移除^M?
在我的Mac中,为Oh-My-Zsh安装的所有文件运行了dos2unix。总而言之,如下所示。我一直在运行~~ .zshrc源,以检查安装是否正常,没有任何错误,直到我转换了所有文件(包括二进制文件)为止。
brew install dos2unix
cd /Users/<your user>/.oh-my-zsh
find . -name “ *.sh” | xargs dos2unix -f
find . -name “ *.zsh” | xargs dos2unix -f
dos2unix -f themes/robbyrussel.zsh-theme
cd
dos2unix -f .zshrc
source ~/.zshrc
Run Code Online (Sandbox Code Playgroud)
解决方案是设置autocrlf=true为autocrlf=false使用以下命令,
git config --global core.autocrlf true
Run Code Online (Sandbox Code Playgroud)
^M 是回车符(CR),Windows样式的文本行结尾为make。