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.
This commit is contained in:
parent
e17ff47d5e
commit
0ab04406ec
5
zprofile
5
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
|
||||
|
16
zshenv
16
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
|
||||
|
||||
|
16
zshrc
16
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 && \
|
||||
|
Loading…
x
Reference in New Issue
Block a user