Shell 加载zsh时出现终端错误(“…未找到命令:^M”)
我正在从oh my zsh转换为prezto。现在,我每次打开终端窗口时都会遇到以下错误:Shell 加载zsh时出现终端错误(“…未找到命令:^M”),shell,terminal,zsh,zshrc,oh-my-zsh,Shell,Terminal,Zsh,Zshrc,Oh My Zsh,我正在从oh my zsh转换为prezto。现在,我每次打开终端窗口时都会遇到以下错误: /Users/jasenlew/.zshenv:7: command not found: ^M /Users/jasenlew/.zshenv:13: parse error near `\n' /Users/jasenlew/.zprofile:7: command not found: ^M /Users/jasenlew/.zprofile:11: command not found: ^M /U
/Users/jasenlew/.zshenv:7: command not found: ^M
/Users/jasenlew/.zshenv:13: parse error near `\n'
/Users/jasenlew/.zprofile:7: command not found: ^M
/Users/jasenlew/.zprofile:11: command not found: ^M
/Users/jasenlew/.zprofile:80: parse error near `\n'
/Users/jasenlew/.zshrc:7: command not found: ^M
/Users/jasenlew/.zshrc:15: parse error near `\n'
/Users/jasenlew/.zlogin:7: command not found: ^M
/Users/jasenlew/.zlogin:15: command not found: ^M
/Users/jasenlew/.zlogin:9: command not found: ^M
/Users/jasenlew/.zlogin:12: command not found: then^M
/Users/jasenlew/.zlogin:16: command not found: ^M
/Users/jasenlew/.zlogin:21: parse error near `\n'
/Users/jasenlew/.zlogin:zcompile:13: can't open file: /Users/jasenlew/.zcompdump^M^M
/Users/jasenlew/.zlogin:14: command not found: fi^M
我已经删除了oh my zsh,并按照此处的repo/说明安装了prezto:
我在谷歌上搜索了一下,并尝试了一些解决方案,但都没有成功,包括将.gitconfig文件中的一行从“autocrlf=true”更改为“autocrlf=false”
我发现字符行距没有被正确处理(让我感到困惑),但我没有完全理解它,解决的方向也很模糊
再次感谢你的帮助 您的
/Users/jasenlew/.z*
文件具有Windows样式的行尾,zsh无法识别
Windows样式文本文件的行尾标记为CR-LF对;CR(回车)通常表示为^M
(Ctrl-M)
UNIX样式的文本文件的行尾仅标记为LF(换行符)字符
zsh采用UNIX样式的行尾,并将CR-LF对视为行尾的^M
字符
只需删除Windows样式的线条端点即可
如果您安装了dos2unix
,您可以使用它。确保阅读手册页;与大多数文本过滤器不同,默认情况下,它将替换其输入文件
或者您可以使用tr
,例如:
tr -d '\r' < filename > filename.tmp
# check filename.tmp to make sure it's correct
mv filename.tmp filename
tr-d'\r'filename.tmp
#检查filename.tmp以确保其正确
mv filename.tmp文件名
您还可以使用file
命令确定您拥有的文件类型。它不是100%可靠的,但它可能会报告给定文件的行尾类型
一旦您修复了行尾,您就可以将文件检查回Git存储库,然后确保它们仍然正常
(你可能还想调整你的
.gitconfig
设置。默认设置应该可以。我不知道我头顶上的细节。)太棒了,基思!非常感谢!!工作得很有魅力!!