Skip to content

Instantly share code, notes, and snippets.

@ccoomber
Last active December 19, 2015 02:49
Show Gist options
  • Save ccoomber/5886028 to your computer and use it in GitHub Desktop.
Save ccoomber/5886028 to your computer and use it in GitHub Desktop.
Bash: Add to PATH
# addToPATH funciton for adding a directory to PATH.
# Prevents duplicate entries and ensures directory exists.
# $1 = Directory to add to PATH
addToPATH(){
if [ -d "${1}" ]; then
case ":${PATH}:" in
*":${1}:"*);; #Directory already in PATH
*) PATH="${PATH}:${1}";; #Append directory to PATH
esac
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment