![Terminal window on a macOS Catalina desktop.](https://i-blog.csdnimg.cn/blog_migrate/086adc6da638c2339aaab4a32a02f4e1.png)
With macOS Catalina, Apple is now using Zsh as the default shell. We love Zsh, but the trusty old Bash shell is still included with macOS, and you can quickly switch back to Bash if you prefer.
借助macOS Catalina ,Apple 现在使用 Zsh作为默认外壳。 我们喜欢Zsh ,但是可信任的旧Bash shell仍包含在macOS中,并且您可以根据需要快速切换回Bash。
Zsh is only the default shell on newly created user accounts, so any existing accounts you have on an upgraded Mac will still use Bash by default unless you change it. Each user account has its own default shell preference.
Zsh只是新创建的用户帐户上的默认外壳程序,因此,默认情况下,除非您进行更改,否则在升级的Mac上拥有的所有现有帐户仍将使用Bash。 每个用户帐户都有其自己的默认外壳程序首选项。
从航站楼 (From the Terminal)
To change a user account’s default shell on macOS, simply run the chsh -s
(change shell) command in a Terminal window.
要在macOS上更改用户帐户的默认外壳,只需在“终端”窗口中运行chsh -s
(更改外壳)命令。
Change the default shell to Bash by running the following command:
通过运行以下命令将默认Shell更改为Bash:
chsh -s /bin/bash
You’ll have to enter your user account’s password. Finally, close the Terminal window and reopen it. You’ll be using Bash instead of Zsh.
您必须输入用户帐户的密码。 最后,关闭“终端”窗口,然后重新打开。 您将使用Bash而不是Zsh。
![Changing the default shell to Bash on macOS Catalina.](https://i-blog.csdnimg.cn/blog_migrate/c0fabaf08a5c9bd0cd716099ef564391.png)
Change the default shell back to Zsh by running this command:
通过运行以下命令,将默认shell更改回Zsh:
chsh -s /bin/zsh
Enter your password when prompted. After you close the terminal window and reopen it, you’ll be using Zsh.
出现提示时输入密码。 关闭终端窗口并重新打开它之后,您将使用Zsh。
![Changing the default shell to Zsh on macOS Catalina.](https://i-blog.csdnimg.cn/blog_migrate/b1919ac93808e0e592d7db5daac37e0c.png)
You can see a list of included shells you can select by running the following command:
您可以通过运行以下命令来查看可以选择的包含外壳的列表:
cat /etc/shells
![Listing available shells in macOS Catalina's terminal.](https://i-blog.csdnimg.cn/blog_migrate/5a9338e05479c4c40350e7a3ff71d76c.png)
从系统偏好设置 (From System Preferences)
You can also change this option graphically from System Preferences if you prefer.
如果愿意,还可以从“系统偏好设置”以图形方式更改此选项。
Head to System Preferences > Users & Groups on your Mac. Click the lock icon and enter your password. Hold the Ctrl key, click your user account’s name in the left pane, and select “Advanced Options.”
转到Mac上的“系统偏好设置”>“用户和组”。 单击锁定图标,然后输入密码。 按住Ctrl键,在左窗格中单击您的用户帐户名称,然后选择“高级选项”。
![Opening Advanced Options in Users & Groups on macOS.](https://i-blog.csdnimg.cn/blog_migrate/84e2a3cfe88035593e2357ad85f0cb18.png)
Click the “Login Shell” dropdown box and select “/bin/bash” to use Bash as your default shell or “/bin/zsh” to use Zsh as your default shell. Click “OK” to save your changes.
单击“登录Shell”下拉框,然后选择“ / bin / bash”将Bash用作默认外壳,或选择“ / bin / zsh”将Zsh用作默认外壳。 单击“确定”保存更改。
![Changing the default login shell graphically in macOS Catalina.](https://i-blog.csdnimg.cn/blog_migrate/0cc93729d383fa3d73cba553c80c8a14.png)
macOS上的Bash仍然过时 (Bash on macOS Is Still Outdated)
Note that the version of Bash (Bourne Again SHell) included with macOS is still pretty outdated, however. If you run bash --version
, you’ll see that Catalina includes Bash 3.2.57 when Bash 5.0 is the latest version. Newer versions are licensed under the GPLv3 license, while Apple still distributes a version licensed under GPLv2.
请注意,macOS随附的Bash(Bourne Again SHell)版本仍然相当过时。 如果运行bash --version
,则当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.
相反,macOS附带的Zsh(Z Shell)版本(请使用zsh --version
检查)为Zsh 5.7.2,这是Catalina发行时的最新版本。
![Viewing the versions of Bash and Zsh on macOS Catalina.](https://i-blog.csdnimg.cn/blog_migrate/95b1f80ce17a34fa13aa60c460bbf4f1.png)
If you want the latest version of Bash, you can install it yourself via Homebrew.
如果您想要最新版本的Bash,可以通过Homebrew自己安装 。
翻译自: https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/