Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 was marked as an exact duplicate of an existing question.

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