Skip to content

Instantly share code, notes, and snippets.

@chorn
Created October 30, 2014 11:30
Show Gist options
  • Save chorn/0b50986deb1066d21430 to your computer and use it in GitHub Desktop.
Save chorn/0b50986deb1066d21430 to your computer and use it in GitHub Desktop.
unset __messy_path
unset __cleaned_path
unset __path_check
declare -A __path_check
__messy_path+=(/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin /Applications/VMware\ Fusion.app/Contents/Library /Applications/Postgres.app/Contents/Versions/{9.3,9.4}/bin /{usr,opt}/{local,X11}/{bin,sbin} $HOME/bin)
__messy_path+=($(IFS=:; echo $PATH))
__messy_path+=(/{usr,opt}/{bin,sbin} /{bin,sbin})
for p in "${__messy_path[@]}" ; do
[[ -d "$p" && -z "${__path_check[$p]}" ]] || continue
__path_check[$p]=1
__cleaned_path+=($p)
done
export PATH=$(IFS=:; echo "${__cleaned_path[*]}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment