Skip to content

Instantly share code, notes, and snippets.

@CarlosMecha
Created December 22, 2014 05:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarlosMecha/3017b58488b84a98da15 to your computer and use it in GitHub Desktop.
Save CarlosMecha/3017b58488b84a98da15 to your computer and use it in GitHub Desktop.
Add additional configuration to the user's Bash profile
#
# Append those lines to the user's `.bashrc`
#
# If the `.bash.d` folder exists, it would 'source' any `sh` script file.
# Keep your configuration organized :)
#
if [ -d ~/.bash.d ]; then {
for i in ~/.bash.d/*.sh; do {
if [ -r $i ]; then {
source $i;
} fi;
} done;
unset i;
} fi;
@alextercete
Copy link

Thanks for sharing!

I'm not sure whether it was intentional or not, but you don't really need the curly braces or semicolon at the end of each statement, so this could be simplified to:

if [ -d ~/.bash.d ]; then
    for file in ~/.bash.d/*.sh; do
        if [ -r $file ]; then
            source $file
        fi
    done

    unset file
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment