macOS .bashrc 无效问题


.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, 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:

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