| 项目 | .bash_profile |
.zshrc |
|---|---|---|
| 对应的 shell | Bash | Zsh |
| macOS 默认使用情况 | macOS 10.15 之前默认是 Bash | macOS 10.15 Catalina 及以后默认是 Zsh |
| 用途 | 登录 shell 配置(设置 PATH 等) | 每次新终端都会加载(设置 PATH、别名、函数等) |
| 执行方式 | source ~/.bash_profile |
source ~/.zshrc |
| 适用于你 | 如果你当前使用的是 bash |
如果你使用的是 zsh(你的情况)✅ |
如何判断你用的是哪个 Shell?
echo $SHELL
/bin/zsh➜ 你用的是 Zsh,应该配置.zshrc/bin/bash➜ 你用的是 Bash,应该配置.bash_profile或.bashrc
在 macOS 中(尤其是 Catalina 及之后版本,默认使用 Zsh),Terminal.app 会加载一系列配置文件,有时候会隐式地加载 .bash_profile,所以 .bash_profile 的变量看起来也生效了。