I am using iTerm in Mac OS X 10.6. It seems when i open iTerm, neither .bashrc nor .bash_profile is sourced. I can tell because the aliases defined in .bashrc don't work. How to fix?

link|improve this question

68% accept rate
feedback

migrated from stackoverflow.com Aug 7 '11 at 9:57

This question came from our site for professional and enthusiast programmers.

4 Answers

up vote 2 down vote accepted

Bash will source EITHER .bash_profile or .bashrc, depending upon how it is called. If it is a login shell, Bash looks for ~/.bash_profile, ~/.bash_login, or ~/.profile, in that order, and sources the first one it finds (and only that one). If it is not a login shell but is interactive (like most terminal sessions), Bash will source ~/.bashrc.

Likely, iTerm is looking for ~/.bashrc. If it's configured to start as a login shell, it will look for ~/.bash_profile. It's almost certainly an error within the config file rather than that the shell is not sourcing it.

I would put a line at the beginning of each file. At the top of ~/.bash_profile:

export BASH_CONF="bash_profile"

And at the top of ~/.bash_profile:

export BASH_CONF="bashrc"

Then, open a new iTerm and type

$ echo $BASH_CONF

That should confirm the file is being sourced and you can look into the syntax of the file.

link|improve this answer
feedback

On my 10.6 machine ~/.profile is sourced. So a source .bashrc entry in ~/.profile should do the job.

link|improve this answer
feedback

Put your alias definitions in the bash profile file, you have to create the file but it will be sourced automatically. I create a separate file called alias.configuration and source it in .bash_profile just because I have another user defined and want to have the same alias set.

link|improve this answer
Actually neither .bashrc nor .bash_profile are sourced. – Computist Aug 7 '11 at 6:02
feedback

In iTerm2, ensure you're using "login shell" instead of a custom command including "login", which doesn't do what you expect.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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