本文介绍了在 zsh 上找不到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 z Shell (zsh) 而不是默认的 bash,并且发生了一些错误,以至于所有曾经工作的命令都不再被识别:

I am using the z Shell (zsh) instead of the default bash, and something wrong happen so that all commands who used to work are no longer recognized:

ls
zsh: command not found: ls

open -e .zshrc
zsh: correct 'open' to '_open' [nyae]?

我不知道如何重置 zsh 或如何解决这个问题.下面是 $PATH 变量的内容:

I don't know how to reset zsh or how to fix this. Here is the content of $PATH variable:

echo $PATH
/Users/Malloc/bin/Sencha/Cmd/3.1.2.342:/usr/local/bin/mate

我无法打开 .bash_profile 文件和 .zshrc 文件,似乎唯一的解决方案是重置 zsh.有任何想法吗?

I cannot open the .bash_profile file nor .zshrc file, seems the only solution is to reset the zsh. Any ideas?

我什至尝试按照 zsh>这个线程,但总是得到command not found错误:

I even tried to reset zsh as indicated in this thread, but always got command not found error:

exec zsh
zsh: command not found: zsh

这是怎么回事?为什么所有命令都丢失了?

so what's going on? why all commands are lost?

推荐答案

很明显,您已经设法弄乱了您的 PATH 变量.(您当前的 PATH 不包含常用实用程序所在的任何位置.)

It's evident that you've managed to mess up your PATH variable. (Your current PATH doesn't contain any location where common utilities are located.)

试试:

PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
export PATH

或者,对于重置"zsh,指定shell的完整路径:

Alternatively, for "resetting" zsh, specify the complete path to the shell:

exec /bin/zsh

exec /usr/bin/zsh

这篇关于在 zsh 上找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 11:39