I have an alias that I've added to .bashrc, and it only activates in Terminal after I run the 'bash' command. I feel like I should know what's happening here, but I don't. :)

  • 2
    If your default shell isn't bash, then bash won't run until you explicitly execute it using the 'bash' command. This would result in the behaviour you seem to experience. Sep 8 '11 at 4:00

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

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


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:


and bash specifically:



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.


The alias doesn't work after you run bash - it works while you're running bash.

Basically, ~/.bashrc is a file that contains directives that are run by bash every time it's started. The default shell for all recent versions of Mac OS X is bash, so it's run every time you open a Terminal. bash does not, however, magically know to re-read its configuration files when you edit them, so the alias doesn't immediately work when you add it to ~/.bashrc. What you do when you run bash in your existing shell is create another instance of bash (which will read the modified configuration file, because it's starting up). Note that your original instance of bash is still there, running behind the bash you ran manually. If you close the shell (with the exit command) you'll return to your original shell (if you close it, you'll get a "process completed" message from the terminal).

So, to get back to your problem: your alias won't work until bash re-reads its configuration. You can do this by starting bash again (either by creating another shell inside your existing shell by running bash, or by closing and opening your terminal) or, you can use the source command to get bash to re-read a file. So, after you've edited ~/.bashrc, do source ~/.bashrc - alias working, no starting bash again.

  • .bashrc is not read every time bash is started.
    – Daniel Beck
    Sep 8 '11 at 11:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.