Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

.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.

share|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

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