]> git.rmz.io Git - dotfiles.git/commitdiff
zsh: configure brew paths using brew --prefix
authorSamir Benmendil <me@rmz.io>
Wed, 24 Jan 2024 15:34:05 +0000 (15:34 +0000)
committerSamir Benmendil <me@rmz.io>
Wed, 24 Jan 2024 15:34:05 +0000 (15:34 +0000)
Only do this when brew is actually installed.

zshrc

diff --git a/zshrc b/zshrc
index 67734d6a81356dbd1fc8e31d6df1b4f70049e9ce..e1e1ff0a2e327a557879fc62b7307f568fe7e4ff 100644 (file)
--- a/zshrc
+++ b/zshrc
@@ -9,9 +9,11 @@ ZSH_CACHE=$XDG_CACHE_HOME/zsh
 # populate path (order matters)
 typeset -U path     # make path a unique array
 # osx gnu utils (installed via brew)
 # populate path (order matters)
 typeset -U path     # make path a unique array
 # osx gnu utils (installed via brew)
-[[ -d /usr/local/opt/coreutils/libexec/gnubin ]] && path=(/usr/local/opt/coreutils/libexec/gnubin $path)
-[[ -d /usr/local/opt/findutils/libexec/gnubin ]] && path=(/usr/local/opt/findutils/libexec/gnubin $path)
-[[ -d /usr/local/opt/gnu-sed/libexec/gnubin ]] && path=(/usr/local/opt/gnu-sed/libexec/gnubin $path)
+if (( $+commands[brew] )); then
+    for pkg in coreutils findutils gnu-sed make; do
+        [[ -d $(brew --prefix $pkg)/libexec/gnubin ]] && path=($(brew --prefix $pkg)/libexec/gnubin $path)
+    done
+fi
 # osx pip 3.7 install
 [[ -d ~/Library/Python/3.7/bin ]] && path=(~/Library/Python/3.7/bin $path)
 # personal scripts
 # osx pip 3.7 install
 [[ -d ~/Library/Python/3.7/bin ]] && path=(~/Library/Python/3.7/bin $path)
 # personal scripts