Created
March 25, 2012 20:18
-
-
Save r10r/2199513 to your computer and use it in GitHub Desktop.
Make adding paths to $PATH and exporting environment variables easy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add all paths listed in ~/.path to the PATH variable | |
# ---------------------------------------------------------- | |
# first check if the file is available | |
if [ -f $HOME/.path ]; then | |
# read file line-by-line | |
for p in $(cat $HOME/.path); do | |
# check if line is a comment | |
if ! echo $p | grep -q ^[[:space:]]*\#; then | |
# check if the directory exists | |
if [ -d "$HOME/$p" ]; then | |
# finally add it to the PATH environent variable | |
PATH=$HOME/$p:$PATH | |
fi | |
fi | |
done | |
fi | |
# Export all declared environment variables listed in ~/.env | |
# check with 'env' so see what is exported | |
# ---------------------------------------------------------- | |
# first check if the file is available | |
if [ -f $HOME/.env ]; then | |
# read file line-by-line | |
for e in $(cat $HOME/.env); do | |
# check if line is a comment | |
if ! echo $p | grep -q ^[[:space:]]*\#; then | |
export $e | |
fi | |
done | |
fi | |
# Load RVM into a shell session *as a function* | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment