Mac 的终端 shell 与 zsh

title: Mac 的终端 shell 与 zsh id: 75edd5b3e062937609fc8c09212a1d05 tags: [] date: 2000/01/01 00:00:00 updated: 2023/01/01 10:45:02 isPublic: true --#|[分隔]|#--

Mac 的终端 shell 与 zsh

之前习惯使用bash,所以重装系统后,使用指令把终端使用的 shell 改为了 bash:

chsh -s /bin/bash

只后安装 nvm 啦、设定一些东西,写在了 ~/.bash_profile 文件中,以便于每次启动终端,自动使用我写的这些配置。

可是后来发现,我每次打开终端,终端都会出现几行多余的字:

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

意思是苹果系统已经把 zsh 作为默认 shell 了,我需要再使用指令 chsh -s /bin/zsh 改回 zsh,否则看它这劲头会一直给我提示,蛋疼。

于是我又使用他提示的这个指令 chsh -s /bin/zsh,把终端使用的 shell 改回了 zsh。

同时,为了让我配置的东西生效,把 ~/.bash_profile 更名为 ~/.zshrc

结果发现更麻烦了,每次启动终端,会提示下面两行,还需要回车操作:

zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?

百度后大致了解到原因,因为有一些不安全的目录,导致有这些提示,可以在终端运行 compaudit 来查看不安全的目录,比如我执行后会打印:

There are insecure directories:
/usr/local/share

解决方案就是去掉这些不安全目录属组的写入权限:

下面两种设置方式依次试一试。

批量设置设置:

单个单个的设置:

之后,再打开终端就干干净净的了。

但是!

我在公司新安装的系统可以解决了,但在家里的笔记本是升级到最新系统的,按照上面步骤执行了,依然没有任何效果。

后来重新安装了 Homebrew,再按照 Homebrew 安装完成后的提示执行指令,彻底解决了。

Last updated

Was this helpful?