Mac – When does mac/ubuntu use .bash_profile and/or .bashrc?


Possible Duplicate:
Difference between .bashrc and .bash_profile

Are they both the same type of file in terms of setting the bash terminal settings, and if no .bash_profile exists then it uses .bashrc?

Also, from within my .bash_profile, can I split my configurations into other files and load them from INSIDE my .bash_profile like:

source .some_file
soource .some_file2

I want to be able to share my .bash_profile file, yet have some private settings kept secret.

I also want to use the same setup for ubuntu and mac, so not sure if things are compatible.

Best Answer

.bash_profile is read if your Bash is called as a login shell, .bashrc for non-login shells.

To split your configuration you can use something like

if [ -d ~/.bash.d ]; then
    for i in ~/.bash.d/*.sh; do
        if [ -r $i ]; then
            . $i
    unset i

That loads all *.sh files in ~/.bash.d/ for which you have read permission.