Tweak bashrc.common

Add a function add_to_path so that it can prepend any specified path
to the PATH environment variable, but only if it is not already there.

Don't worry about (re)setting the LS_COLORS environment if it's already
been set by the system bashrc.
vimbundler
nirenjan 2013-01-30 10:27:39 -08:00
parent 13fae1e870
commit 5e4648a49e
1 changed files with 10 additions and 5 deletions

View File

@ -1,3 +1,10 @@
# Add path function: check if path exists in $PATH, only then prepend the
# specified path to PATH
add_to_path() {
if [[ ! -z $1 && -d $1 && ":$PATH:" != *":$1:"* ]]; then
export PATH=$1:$PATH
fi
}
# Import the Git prompt shell functions. These can be found # Import the Git prompt shell functions. These can be found
# @github:git/git/contrib/completion/git_prompt.sh # @github:git/git/contrib/completion/git_prompt.sh
@ -9,13 +16,11 @@ else
fi fi
# Add $HOME/bin to PATH # Add $HOME/bin to PATH
if [[ ":$PATH:" != *":$HOME/bin:"* ]] add_to_path $HOME/bin
then
export PATH=$HOME/bin:$PATH
fi
# Add ls coloring # Add ls coloring
if [ -f $HOME/.bashrc.lscolors ]; then # Don't bother if LS_COLORS is already set
if [[ -z $LS_COLORS && -f $HOME/.bashrc.lscolors ]]; then
source $HOME/.bashrc.lscolors source $HOME/.bashrc.lscolors
fi fi