From 0ab04406ecd45d9feb50a845758d85b2f8edcae5 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sun, 26 Aug 2018 20:17:24 +0100 Subject: [PATCH] Fix macOS PATH being rewritten in /etc/zprofile macOS is obnoxious and overwrites the PATH from a users ~/.zshenv, which is sourced first, in /etc/zprofile by calling `/usr/libexec/path_helper -s` so this is required so that PATH is once again set to the desired value. --- zprofile | 5 +++++ zshenv | 16 +++++++++++++++- zshrc | 16 ---------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/zprofile b/zprofile index 418d452..b2703f1 100644 --- a/zprofile +++ b/zprofile @@ -1,2 +1,7 @@ # .zprofile [1] Used for executing user's commands at start, will be sourced # when starting as a login shell. + +# macOS is obnoxious and overwrites the PATH from a users ~/.zshenv, which is +# sourced first, in /etc/zprofile by calling `/usr/libexec/path_helper -s` so +# this is required so that PATH is once again set to the desired value. +[ `uname` = Darwin ] && source ~/.zshenv diff --git a/zshenv b/zshenv index cf206e7..e90d509 100644 --- a/zshenv +++ b/zshenv @@ -12,7 +12,7 @@ SAVEHIST=5000 REPORTTIME=5 # Add Homebrew python to PATH on macOS if present -[ "`uname`" = "Darwin" ] && [ -d /usr/local/opt/python/libexec/bin ] && +[ -d /usr/local/opt/python/libexec/bin ] && \ PATH=/usr/local/opt/python/libexec/bin:$PATH # Add ~/.local to the environment @@ -21,6 +21,20 @@ PATH=$HOME/.local/bin:$PATH MANPATH=$HOME/.local/share/man:$MANPATH INFOPATH=$HOME/.local/share/info:$INFOPATH +if [ `uname` = Darwin ]; then + [ -f /usr/local/bin/ccache ] && \ + PATH=/usr/local/opt/ccache/libexec:$PATH +else + [ -f /usr/bin/ccache ] && \ + PATH=/usr/lib/ccache:$PATH +fi + +# Remove duplicates from environment variables +typeset -U fpath +typeset -U PATH; export PATH +typeset -U MANPATH; export MANPATH +typeset -U INFOPATH; export INFOPATH + # Use ~/.local for pip installs on macOS [ "`uname`" = "Darwin" ] && export PYTHONUSERBASE=$HOME/.local diff --git a/zshrc b/zshrc index 7552b5f..4c849fd 100644 --- a/zshrc +++ b/zshrc @@ -158,22 +158,6 @@ fi # Load work related config [ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc -# Remove duplicates from environment variables -typeset -U PATH -typeset -U MANPATH -typeset -U INFOPATH - -# Add ccache symlink directory to start of PATH, this must be after -# `typeset -U PATH` because on macOS this reorders the list so ccache's -# symlinks will no longer be at the start of PATH rendering it unusable. -if [ `uname` = Darwin ]; then - [ -f /usr/local/bin/ccache ] && \ - PATH=/usr/local/opt/ccache/libexec:$PATH -else - [ -f /usr/bin/ccache ] && \ - PATH=/usr/lib/ccache:$PATH -fi - # Aliases alias grep='grep --color=always' which cmake &> /dev/null && \