Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function prepend_path () {
local path; path=$1; shift
export PATH="$(
awk -v RS=: -v "prepend=$path" '
BEGIN { a = prepend ":" }
$0 != prepend { a = a $0 ":" }
END { print(substr(a, 1, length(a)-1)) }
' <<< $PATH
)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.