unix系统中, 常用的初始化脚本有两个:.bashrc 和 .bash_profile,比较容易混淆。
这两个脚本的主要区别在于,触发执行的条件不一样:
- .bash_profile 使用用户名、密码登录成功之后,会被触发执行
- .bashrc 打开新的窗口,比如 ubuntu terminal中输入 ctrl + shift + t,会打开新窗口,此时执行 .bashrc 脚本
一般来说,为了防止 .bash_profile 和 .bashrc 两个脚本的内容有重合,可以在 .bash_profile 中加入以下内容:
if [ -f ~/.bashrc ]; then source ~/.bashrc fi