What happens exactly when I type 'bash' on the Terminal command line on Mac OSX?

From man bash:

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

Emphasis mine

On OS X, all Terminal windows and tabs run login shells, which is equivalent to you running bash --login instead of bash. ~/.bashrc is therefore ignored, unless explicitely sourced from e.g. ~/.bash_profile:

When bash is invoked as an interactive login shell, [...] it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

Just create ~/.bash_profile if it doesn't exist, and add the following line:

. .bashrc

Then .bashrc will be loaded even for login sessions.


Depending on the version of OS X you are using your default shell might not be bash. You can verify this by typing(before you run 'bash'):

$ echo $SHELL
/bin/zsh

You can change your default shell to bash so you don't have to keep running the command by following the instructions here:

https://serverfault.com/questions/21044/how-do-i-change-a-users-default-shell-in-osx

From @chopper3

for <=10.4 - netinfo manager, /users/whoever/shell

for 10.5=> - SysPrefs, accounts, control-click on user, select advanced options, edit login shell field.

To further answer your question, the .bashrc is only used by the bash shell. If you want you can figure out what shell you are using and add the alias to the .tcshrc or .zshrc instead of changing everything to use bash.

More info on what a shell is:

http://en.wikipedia.org/wiki/Shell_(computing)

and bash specifically:

http://en.wikipedia.org/wiki/Bash_(Unix_shell)