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.

link|improve this question

48% accept rate
feedback

closed as exact duplicate by Gilles, Sathya May 20 '11 at 4:04

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

1 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
        fi
    done
    unset i
fi

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

link|improve this answer
I believe it's actually both read and execute permissions. – Hello71 May 14 '11 at 1:34
@Hello71: No, the snippet above only checks for read using -r, and sources the file instead of executing it. – grawity May 14 '11 at 14:49
feedback

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