Apple - Why must I source .bashrc every time I open terminal for aliases to work?

In short, you are putting your aliases in the wrong file .bashrc, that is why you need to keep running source to get the aliases working in any new login terminal instances.

From Chris Johnsen's comment at Why doesn't .bashrc run automatically?

By default, Terminal starts the shell via /usr/bin/login, which makes the shell a login shell. On every platform (not just Mac OS X) bash does not use .bashrc for login shells (only /etc/profile and the first of .bash_profile, .bash_login, .profile that exists and is readable). This is why “put source ~/.bashrc in your .bash_profile” is standard advice.

For more information, see the manual page for bash:

man bash

Then look under the INVOCATION section.


You can always put

if [ -n "$BASH_VERSION" ] && [ -f $HOME/.bashrc ];then
    source $HOME/.bashrc
fi

into the file ~/.profile or ~/.bash_profile on mac I think.

Oooor, you could just put your stuff in .profile or .bash_profile.

Tags:

Bash

Alias