Why doesn't .bashrc run automatically?

Just put that in your .profile file from your home dir and it should work the next time you start a new shell or after you run source ~/.profile

This link clearly states the order in which the startup files are read and loaded by the shell: http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup


Been there, done that. What I came aware of, OS X doesn't read .bashrc file on bash start. Instead, it reads the following files (in the following order):

  1. /etc/profile
  2. ~/.bash_profile
  3. ~/.bash_login
  4. ~/.profile

See also Chris Johnsen's informative and useful comment:

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

I usually just put the things that I'd normally put in ~/.bashrc to ~/.profile — has worked so far like a charm.


I put everything into ~/.bashrc and just source ~/.bashrc in .profile.

This allows screen and xterm (and i guess tmux) sessions to inherit my environment as non-login sessions only run .bashrc, whereas login sessions (eg terminal or iTerm) only run .profile.