参考上一篇文章说明:http://www.cnblogs.com/EasonJim/p/6283094.htmlhtml
得知加载顺序以下:shell
/etc/profilebash
/etc/pathsspa
~/.bash_profilecode
~/.bash_loginhtm
~/.profileblog
~/.bashrcget
固然/etc/profile和/etc/paths是系统级别的,系统启动就会加载,后面几个是当前用户级的环境变量。后面3个按照从前日后的顺序读取,若是~/.bash_profile文件存在,则后面的几个文件就会被忽略不读了,若是~/.bash_profile文件不存在,才会以此类推读取后面的文件。~/.bashrc没有上述规则,它是bash shell打开的时候载入的。it
也就是说在当前用户的目录下,若是又了.bash_profile文件就不会去加载.bashrc文件。io
因此若是要能正常加载.bashrc文件,须要在.bash_profile文件的最末尾上加入以下语句:
if [ -f ~/.bashrc ]; then source ~/.bashrc fi
参考:http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
然而,这个修改只是正对base的,若是你没有修改过,上面的方法默认重启后就能生效。
可是,如今的mac上有些使用zsh这个做为默认的shell,因此,在启动shell时,默认不会按上面的套路去加载。
若是想要正常加载.bashrc文件时,就要找到用户目录下的.zlogin文件加入以下代码:
if [ -f ~/.bashrc ]; then source ~/.bashrc fi
便可生效。
参考思路:
http://superuser.com/questions/866683/iterm-zsh-not-reading-bashrc-or-bash-profile