<分区>
我在我的 Mac 上安装了 zsh。现在我想让它成为默认的 shell 而不是 Bash。但我似乎遇到了以下错误:
$ echo $SHELL
/bin/bash
$ chsh -s /usr/bin/zsh
Changing shell for harshamv.
Password for harshamv:
chsh: /usr/bin/zsh: non-standard shell
<分区>
我在我的 Mac 上安装了 zsh。现在我想让它成为默认的 shell 而不是 Bash。但我似乎遇到了以下错误:
$ echo $SHELL
/bin/bash
$ chsh -s /usr/bin/zsh
Changing shell for harshamv.
Password for harshamv:
chsh: /usr/bin/zsh: non-standard shell
最佳答案
正确答案应该已经解决了您的问题:
chsh: /usr/bin/zsh: non-standard shell
出现这种情况的原因是 chsh
将只接受在文件/etc/shells 中定义的 shell,正如您阅读 chsh
的手册所见>:
chsh will accept the full pathname of any executable file on the system. However, it will issue a warning if the shell is not listed in the /etc/shells file.
要解决此问题并使 zsh 成为默认 shell,您应该:
$ sudo echo "$(which zsh)" >> /etc/shells
$ chsh -s $(which zsh)
显然,我假设 zsh
在您的路径中。例如,如果您选择使用 brew install zsh
安装最新的 zsh
,此解决方案也适用。
编辑(感谢 ThisIsFlorianK 的评论):
根据您的 shell 设置,您可能会收到一条消息,内容为 /etc/shells: Permission denied
。您可以找到有关此问题的信息 here.
要解决此问题,请改用以下内容:
$ sudo sh -c "echo $(which zsh) >> /etc/shells"
$ chsh -s $(which zsh)
关于bash - 在 MacOS 中使 ZSH 默认 Shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31034870/