bash: check for brew after PATH manipulation

This commit is contained in:
Fernando Schauenburg 2021-01-03 22:19:52 +01:00
parent b16ca6a626
commit c141e51b66

View file

@ -23,11 +23,6 @@ export LESSHISTFILE="$XDG_DATA_HOME/less/history"
export LESSHISTSIZE=1000 export LESSHISTSIZE=1000
export LOCAL_CONFIG="$HOME/.local/etc" export LOCAL_CONFIG="$HOME/.local/etc"
export LOCAL_PREFIX="/usr/local" export LOCAL_PREFIX="/usr/local"
if command -v brew &>/dev/null; then
LOCAL_PREFIX="$(brew --prefix)"
export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_AUTO_UPDATE=1
fi
MANPATH="$(unset MANPATH; manpath)" MANPATH="$(unset MANPATH; manpath)"
export MANPATH export MANPATH
export PAGER=less export PAGER=less
@ -35,17 +30,13 @@ export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup.py"
# shellcheck disable=SC2016 # This expression is to be interpreted by vim, not bash. # shellcheck disable=SC2016 # This expression is to be interpreted by vim, not bash.
export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC' export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC'
##############################################################################
# Customize PATH (and MANPATH)
##############################################################################
# Prevent path_helper from messing with the PATH when starting tmux. # Prevent path_helper from messing with the PATH when starting tmux.
# See: https://superuser.com/a/583502 # See: https://superuser.com/a/583502
# shellcheck disable=SC2123 # PATH is being intentionally manipulated here. # shellcheck disable=SC2123 # PATH is being intentionally manipulated here.
# shellcheck disable=SC1091 # /etc/profile is provided by macOS. # shellcheck disable=SC1091 # /etc/profile is provided by macOS.
[ "$(uname)" == "Darwin" ] && { PATH=""; source /etc/profile; } [ "$(uname)" == "Darwin" ] && { PATH=""; source /etc/profile; }
_prepend_path() { # 1: dir to add, 2: path variable to manipulate _prepend_path() { # prepend $1 to variable $2 using : as separator
if [ -d "$1" ] && [ -n "$2" ]; then if [ -d "$1" ] && [ -n "$2" ]; then
local _path="${!2}" # get path variable value local _path="${!2}" # get path variable value
case ":$_path:" in case ":$_path:" in
@ -76,7 +67,14 @@ while read -r dir; do _prepend_path "$dir" MANPATH; done <<EOL
$HOME/.local/share/man $HOME/.local/share/man
EOL EOL
unset dir unset dir _prepend_path
# This check has to be done after PATH manipulation above so we can find brew.
if command -v brew >/dev/null 2>&1; then
LOCAL_PREFIX="$(brew --prefix)"
export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_AUTO_UPDATE=1
fi
stty -ixon # disable ctrl-s and ctrl-q stty -ixon # disable ctrl-s and ctrl-q
command -v solarize >/dev/null && solarize command -v solarize >/dev/null && solarize