macOS .bashrc 无效问题

一般的linux机器配置.bashrc就可以,但在Mac上这个文件不起作用。

.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

Mac OS X — an exception
An exception to the terminal window guidelines is Mac OS X’s Terminal.app, which runs a login shell by default for each new terminal window, calling .bash_profile instead of .bashrc. Other GUI terminal emulators may do the same, but most tend not to.

If you want your aliases to work in both login and non-login shells (and you usually do), you should put them in .bashrc and source .bashrc in your .bash_profile, with a line like this:


1
[ -r ~/.bashrc ] && source ~/.bashrc


参考: