用 macOS卡塔利娜 ,苹果是 现在使用 Zsh作为默认外壳。 我们爱Zsh ,但可信任的旧Bash shell仍包含在macOS中,并且您可以根据需要快速切换回Bash。
Zsh只是新创建的用户帐户上的默认外壳程序,因此默认情况下,除非您进行更改,否则您在升级的Mac上拥有的任何现有帐户仍将使用Bash。每个用户帐户都有其自己的默认外壳程序首选项。
从航站楼
更改用户帐户’s default shell on macOS, simply run the chsh -s
(change shell) command in a Terminal window.
通过运行以下命令将默认Shell更改为Bash:
chsh -s /bin/bash
您’必须输入您的用户帐户’的密码。最后,关闭“终端”窗口,然后重新打开。您’将使用Bash代替Zsh。
通过运行以下命令,将默认shell更改回Zsh:
chsh -s /bin/zsh
出现提示时输入密码。关闭终端窗口并重新打开之后,您将’ll be using Zsh.
您 can see a list of included shells you can select by running the following command:
cat /etc/shells
从系统偏好设置
您 can also change this option graphically from System Preferences if you prefer.
前往系统偏好设置> Users &Mac上的群组。单击锁定图标,然后输入密码。按住Ctrl键,然后单击您的用户帐户’的名称在左窗格中,然后选择“Advanced Options.”
点击“Login Shell”下拉框,然后选择“/bin/bash”使用Bash作为您的默认Shell或“/bin/zsh”使用Zsh作为默认外壳。请点击“OK”保存您的更改。
macOS上的Bash仍然过时
Note that the version of Bash (Bourne Again SHell) included with macOS is still pretty outdated, however. If you run bash --version
, you’我们会看到,当Bash 5.0是最新版本时,Catalina包括Bash 3.2.57。较新的版本已获得GPLv3许可,而Apple仍在分发已获得GPLv2许可的版本。
In contrast, the version of Zsh (Z shell) included with macOS (check with zsh --version
), is Zsh 5.7.2, which is the latest version at the time of Catalina’s release.
如果您想要最新版本的Bash,可以 通过Homebrew自己安装.