Fix PATH setup on macOS

This commit is contained in:
2020-02-22 18:14:58 +00:00
parent 80c77c8c2b
commit f55a087fe1
2 changed files with 28 additions and 8 deletions

24
zshenv
View File

@@ -2,9 +2,27 @@
# ZSH Environment Setup
#
# Ensure values in path variable are unique.
# Ensure values in path variable are unique
typeset -U path
# Prevent loading ZSH startup from files /etc on macOS. The /etc/zprofile file
# screws around with PATH, so we want to avoid it, and instead manually load the
# files we care about.
if [[ "$OSTYPE" == "darwin"* ]]; then
# Disable loading startup files from /etc
unsetopt GLOBAL_RCS
# Setup default PATH just like /etc/zprofile does
if [ -x "/usr/libexec/path_helper" ]; then
eval `/usr/libexec/path_helper -s`
fi
# Load /etc/zshenv if it exists
if [ -f "/etc/zshenv" ]; then
source "/etc/zshenv";
fi
fi
# Path helpers
path_list () {
print -l "${(@)path}"
@@ -49,10 +67,10 @@ if [[ "$TMPDIR" == "/var/folders/"* ]] || [[ "$TMPDIR" == "" ]]; then
mkdir -p "$TMPDIR"
fi
# Ensure basic systems paths are in desired order.
# Ensure basic systems paths are in desired order
path_prepend "/sbin"
path_prepend "/bin"
path_prepend "/usr/sbin"
path_prepend "/bin"
path_prepend "/usr/bin"
path_prepend "/usr/local/sbin"
path_prepend "/usr/local/bin"