Joh*_*n T 24
chsh
像这样使用该实用程序:
chsh -s bash
Run Code Online (Sandbox Code Playgroud)
例如chsh
,与chsh
您在 Linux 中看到的相比,Apple在 Mac OS X 上发生了一些变化。您可以在chsh Mac OS X 手册页中阅读他们的内容。
Tel*_*hus 22
请注意,您将只被允许更改为/etc/shells
. 这通常没问题,但这意味着如果您想安装 Bash 4(来自 Homebrew、MacPorts 或自己编译),您需要在 .bashrc 中添加一行/etc/shells
。(几周前我遇到了这个,并认为它可能有助于其他人知道......)
编辑:Tim Smith指出,/etc/shells
如果您chsh
以 root 身份通过sudo
. 例如sudo chsh -s /usr/local/bin/my_shell $USER
,即使my_shell
未列在/etc/shells
. 我更喜欢 edit /etc/shells
,但最终,这是sudo
两种方式的一种用途,因为您无法/etc/shells
以普通用户的身份进行编辑。所以也许一个六个,另一个六个。
使用上面的答案,我收到一条错误消息:
$ chsh -s zsh
Changing shell for myuser.
Password for myuser:
chsh: zsh: non-standard shell
Run Code Online (Sandbox Code Playgroud)
要解决此问题:
sudo chsh -s zsh $(whoami)
Run Code Online (Sandbox Code Playgroud)
whoami
在子shell中是为您的用户更改shell,而不是root。
如果您使用自制软件,还有一件事。当您以 root 身份(使用sudo
)运行命令时,zsh 指向 /bin/zsh,它随 OSX 一起提供并且可能已过时。要使用通过自制软件安装的最新版本,请使用以下命令:
sudo chsh -s $(which zsh) $(whoami)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20975 次 |
最近记录: |