Bash是一种Shell,一般 Linux 都会带,其他种类的 Shell(比如Mac的zsh)也可以参考 Bash 的配置方式
| 文件 | 加载时机 |
| .bash_profile | login shell(如通过 SSH 登录、TTY 登录) |
| .bashrc | interactive non-login shell(如在图形终端打开新 terminal) |
如果登录的是 login shell(比如通过 SSH、或是在某些系统里打开 Terminal),只执行 .bash_profile,不会自动执行 .bashrc(可以手动source ~/.bashrc但是比较麻烦)。但是我们的配置一般都写在 .bashrc 里面,所以建议在 .bash_profile 中添加以下内容:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi