Skip to content

Instantly share code, notes, and snippets.

@burke
Created September 28, 2018 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burke/8c970d80c2c0e6bbacfd2a391ee0825d to your computer and use it in GitHub Desktop.
Save burke/8c970d80c2c0e6bbacfd2a391ee0825d to your computer and use it in GitHub Desktop.
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