@@ -40,14 +40,33 @@ _add_to_path "$HOME/.local/bin"
4040# To make Homebrew's completions available
4141# https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh
4242# Note: brew shellenv is slow (~100-300ms), so we manually set the essentials
43- if [[ -d " /opt/homebrew" ]]; then
44- export HOMEBREW_PREFIX=" /opt/homebrew"
45- export HOMEBREW_CELLAR=" /opt/homebrew/Cellar"
46- export HOMEBREW_REPOSITORY=" /opt/homebrew"
47- fpath+=(" /opt/homebrew/share/zsh/site-functions" )
48- # HOMEBREW_SHELLENV_PREFIX is set for compatibility
49- export HOMEBREW_SHELLENV_PREFIX=" /opt/homebrew"
50- fi
43+ _setup_homebrew () {
44+ local homebrew_root=0
45+
46+ if [[ $( uname -s) == ' Darwin' ]]; then
47+ homebrew_root=' /opt/homebrew'
48+ elif [[ $( uname -s) == ' Linux' ]]; then
49+ homebrew_root=' /home/linuxbrew/.linuxbrew'
50+ fi
51+
52+ if [[ -d $homebrew_root ]]; then
53+ # --- Homebrew Setup (ARM/M1+ only)
54+ # Add Homebrew paths first (needed for macOS, no-op on Linux if paths don't exist)
55+ _add_to_path " $homebrew_root /bin"
56+ _add_to_path " $homebrew_root /sbin"
57+
58+ export HOMEBREW_PREFIX=" $homebrew_root "
59+ export HOMEBREW_CELLAR=" $homebrew_root /Cellar"
60+ export HOMEBREW_REPOSITORY=" $homebrew_root "
61+ # HOMEBREW_SHELLENV_PREFIX is set for compatibility
62+ export HOMEBREW_SHELLENV_PREFIX=" $homebrew_root "
63+
64+ fpath+=(" $homebrew_root /share/zsh/site-functions" )
65+
66+ eval " $( $homebrew_root /bin/brew shellenv) "
67+ fi
68+ }
69+ _setup_homebrew
5170# Homebrew Setup ---
5271
5372# Function to check if zsh completion cache needs regeneration
@@ -88,7 +107,7 @@ _source_if_exists "$Z_CONFIG_DIR/plugins/zsh-autosuggestions/zsh-autosuggestions
88107# True lazy loading for syntax highlighting - load on first edit
89108zsh-syntax-highlighting-lazy-load () {
90109 unset -f $0
91- source " $Z_CONFIG_DIR /plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
110+ _source_if_exists " $Z_CONFIG_DIR /plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
92111}
93112
94113autoload -Uz add-zsh-hook
@@ -151,7 +170,7 @@ _source_if_exists "$Z_CONFIG_DIR/secondary.zsh"
151170 if command -v ng & > /dev/null; then
152171 source <( ng completion script)
153172 fi
154-
173+
155174 # Docker completion styles
156175 zstyle " :completion:*:*:docker:*" option-stacking yes
157176 zstyle " :completion:*:*:docker-*:*" option-stacking yes
0 commit comments