1

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.

0

1 Answer 1

0

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

2
  • I believe it's actually both read and execute permissions.
    – Hello71
    May 14, 2011 at 1:34
  • @Hello71: No, the snippet above only checks for read using -r, and sources the file instead of executing it. May 14, 2011 at 14:49

Not the answer you're looking for? Browse other questions tagged .