Skip to content

Instantly share code, notes, and snippets.

@jeffmccune
Created June 4, 2014 23:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffmccune/c59edc4b760fb12ded7c to your computer and use it in GitHub Desktop.
Save jeffmccune/c59edc4b760fb12ded7c to your computer and use it in GitHub Desktop.
/usr/libexec/path_helper is not
# F!@#!$ing Apple calling /usr/libexec/path_helper from the always executed
# /etc/zshenv which has the result of re-ordering the PATH in a way we can't
# control.
#
# See: https://github.com/sorin-ionescu/prezto/issues/381#issuecomment-12745303
# Approach:
# 1: Store our current path, which is messed up by apple.
# 2: Determine the Apple default path.
# 3: Subtract the default path from the screwed up path.
# 4: Append the default path to the results of 3.
#
# Result: Our stuff will be first, and in the correct order, followed by the
# path_helper defaults
if [ -x /usr/libexec/path_helper ]; then
FP="${PATH}"
eval "$(PATH='' /usr/libexec/path_helper)"
DP="${PATH}"
PATH=$(/usr/bin/ruby -e "fp=%{$FP}.split(%{:}); dp=%{$DP}.split(%{:}); p=fp-dp+dp; puts p.join(%{:});")
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment