Created
April 6, 2017 15:59
-
-
Save webee/76dd1c893181e822a182bda8a41440d8 to your computer and use it in GitHub Desktop.
pathmunge
This file contains hidden or 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
function pathmunge { | |
if echo $PATH | /usr/bin/egrep -q "(^|:)$1($|:)";then | |
a=${1//\//\\\/} | |
PATH=$(echo $PATH|/usr/bin/sed -e "s/\([:^]*\)$a\([$:]*\)/\1\2/g") | |
PATH=$(echo $PATH|/usr/bin/sed -e 's/::/:/g'|/usr/bin/sed -e 's/^://g'|/usr/bin/sed -e 's/:$//g') | |
fi | |
if [ "$2" = "after" ];then | |
PATH=$PATH:$1 | |
else | |
PATH=$1:$PATH | |
fi | |
export PATH | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment