Skip to content

Instantly share code, notes, and snippets.

@mkb
Created December 6, 2012 22:36
Show Gist options
  • Select an option

  • Save mkb/4229114 to your computer and use it in GitHub Desktop.

Select an option

Save mkb/4229114 to your computer and use it in GitHub Desktop.
Prepend to path, removing any duplicates present
prepend_path()
{
PATH=$1:$PATH
PATH="$(printf "%s" "${PATH}" | /usr/bin/awk -v RS=: -v ORS=: '!($0 in a) {a[$0]; print}')"
PATH="${PATH%:}"
export PATH
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment