Using .bashrc with Terminal
I got a question from a user today that was pretty interesting. Boiled down, it was “I’ve set up a .bashrc file with my preferred settings. It works fine in XWindows with xterm, but is being ignored by Terminal. Why?”
This has to do with how the bash shell handles different shells. If you read the bash man page (‘man bash’), in the section on startup files, it explains which files are read when. The tricky part is that there are two types of shells: “login” shells and “non-login” shells, and bash reads different files depending on the type of shell.
A “login” shell reads ~/.profile but not ~/.bashrc
A “non-login” shell reads ~/.bashrc but not ~/.profile
A new Terminal window in OS X starts a “login” shell and hence reads ~/.profile but not ~/.bashrc
The situation is reversed for xterm (running under X11 in OS X).
What should fix it is to set up a .profile file to that sources your .bashrc file like this:
if [ -f ~/.bashrc ]; then
That way, you don’t have to worry about making changes to .profile; Terminal will just get the changes from .bashrc. For what it’s worth, this is an issue with several Unix-based OSs.