I always forget which file to use when I want to change something in my environment. It doesn’t help that Terminal.app in OS X behaves a little differently than other *nix terminals. Thankfully, John Staiger posted a very clear explanation and a handy trick a few years back.
The short version is this: .bash_profile runs when you log in, .bashrc runs when you open a new terminal window EXCEPT in OS X which treats each new terminal window as a new login for some reason.
Staiger’s suggestion is to keep all your settings in .bashrc and just tell .bash_profile to call .bashrc so you don’t end up managing two files (click through for his .bash_profile contents). This works just fine, but I don’t know that I’ve even run into a situation in OS X where .bashrc would be loaded instead of .bash_profile so it’s probably just as easy to keep everything in .bash_profile and never create .bashrc.
I imagine the trick would be more helpful if you’re working in different distros and want to manage your environment the same way regardless of which OS you’re currently on.
One thought on “.bash_profile or .bashrc in OS X?”