summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlen <alen@dotfiles.xyz>2025-01-19 19:33:32 +0400
committerAlen <alen@dotfiles.xyz>2025-01-19 19:33:32 +0400
commit534899e2986732a569d15f231637447833a360b0 (patch)
tree8e2d1719ec9df2e0b17a867303892897122d7060
parent81f3e6dcbf1913a2ba2a8f5fe2219b5206f270c0 (diff)
Tidy up PATH bootstrapping, set up core brew PATHs in zshenv
-rw-r--r--dot_config/zsh/dot_zshrc13
-rw-r--r--dot_local/share/zsh/brew/brew.plugin.zsh8
-rw-r--r--dot_zshenv19
3 files changed, 23 insertions, 17 deletions
diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc
index 642957b..9f3c137 100644
--- a/dot_config/zsh/dot_zshrc
+++ b/dot_config/zsh/dot_zshrc
@@ -12,9 +12,6 @@ RPROMPT="%(?.%F{10}%?.%F{9}%?)%f %T"
 autoload -U compaudit compinit zrecompile giti
 autoload -U colors && colors
 
-
-export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:${PATH}"
-
 # zinit
 declare -A ZINIT
 ZINIT[HOME_DIR]="${XDG_CONFIG_HOME}/zinit"
@@ -134,18 +131,8 @@ if [[ -f "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Curren
     alias airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
 fi
 
-# JetBrains Toolbox
-if [[ -d "${HOME}/Library/Application Support/JetBrains/Toolbox/scripts" ]]; then
-    export PATH="${PATH}:${HOME}/Library/Application Support/JetBrains/Toolbox/scripts"
-fi
-
 export FZFZ_RECENT_DIRS_TOOL="fasd"
 
-# Rust
-if [[ -d "${HOME}/.cargo/bin" ]]; then
-    export PATH="${PATH}:${HOME}/.cargo/bin"
-fi
-
 safari_history() {
   sqlite3 -box -readonly ~/Library/Safari/History.db <<SQL
 WITH ranked_visits AS (
diff --git a/dot_local/share/zsh/brew/brew.plugin.zsh b/dot_local/share/zsh/brew/brew.plugin.zsh
index e929174..8d9113a 100644
--- a/dot_local/share/zsh/brew/brew.plugin.zsh
+++ b/dot_local/share/zsh/brew/brew.plugin.zsh
@@ -1,13 +1,13 @@
 # Set up brew
-if [[ -f /opt/homebrew/bin/brew ]]; then
+if [[ -v HOMEBREW_PREFIX ]] && [[ -f "${HOMEBREW_PREFIX}/bin/brew" ]]; then
     export HOMEBREW_NO_ENV_HINTS=1
     export HOMEBREW_NO_ANALYTICS=1
-    eval "$(/opt/homebrew/bin/brew shellenv)"
-    fpath=("/opt/homebrew/share/zsh/site-functions" $fpath)
+    eval "$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
+    fpath=("${HOMEBREW_PREFIX}/share/zsh/site-functions" $fpath)
 
     # Prefer GNU versions of certain tools
     local tool_bin
-    for tool_bin in /opt/homebrew/opt/*/libexec/gnubin(N); do
+    for tool_bin in "${HOMEBREW_PREFIX}"/opt/*/libexec/gnubin(N); do
         if [[ "${tool_bin}" == */gsed/* ]]; then
             continue  # Alias to gnu-sed
         fi
diff --git a/dot_zshenv b/dot_zshenv
index 5d41124..0b222c7 100644
--- a/dot_zshenv
+++ b/dot_zshenv
@@ -73,3 +73,22 @@ export BAT_CONFIG_FILE="${XDG_CONFIG_HOME:-${HOME}/.config}/bat/config"
 
 # Brew config
 HOMEBREW_BUNDLE_FILE_GLOBAL="${XDG_CONFIG_HOME:-${HOME}/.config}/Brewfile"
+
+# Homebrew to PATH - also set in brew.plugin.zsh, but de-duped
+export HOMEBREW_PREFIX=/opt/homebrew
+if [[ -d "${HOMEBREW_PREFIX}/sbin" ]]; then
+    export PATH="${HOMEBREW_PREFIX}/sbin:${PATH}"
+fi
+if [[ -d "${HOMEBREW_PREFIX}/bin" ]]; then
+    export PATH="${HOMEBREW_PREFIX}/bin:${PATH}"
+fi
+
+# JetBrains Toolbox to PATH
+if [[ -d "${HOME}/Library/Application Support/JetBrains/Toolbox/scripts" ]]; then
+    export PATH="${PATH}:${HOME}/Library/Application Support/JetBrains/Toolbox/scripts"
+fi
+
+# Rust to PATH
+if [[ -d "${HOME}/.cargo/bin" ]]; then
+    export PATH="${PATH}:${HOME}/.cargo/bin"
+fi