diff options
| author | Igor Soarez <igor@soarez.org> | 2026-09-21 15:26:23 +0300 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-09-21 15:26:23 +0300 |
| commit | d312cb2acca4cff77c82ea4467585e0a2814c47c (patch) | |
| tree | 21686d25d794cfca4707a1794be731ae3852ed6e | |
| parent | 73031b778fa3460181be045bf06587917c13ebd5 (diff) | |
zshrc: find Homebrew's completions on the prefix this machine uses
fpath carried /usr/local/share/zsh-completions, which is wrong twice over:
Apple Silicon puts Homebrew under /opt/homebrew, and formulae install their
completions into share/zsh/site-functions, not the share/zsh-completions of
the formula by that name. The directory existed on neither Mac, so _brew,
_bat, _deno and the rest have been missing all along -- silently, since a
missing fpath entry says nothing.
All four candidates are probed now, HOMEBREW_PREFIX first where a machine
exports it. No `brew --prefix`: that forks on every interactive shell, and
this file already pays for one of those further down.
| -rwxr-xr-x | config/zshrc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/config/zshrc b/config/zshrc index f211999..0b22223 100755 --- a/config/zshrc +++ b/config/zshrc @@ -12,8 +12,22 @@ bindkey \^U backward-kill-line # Enable Ctrl-x-e to edit command line autoload -U edit-command-line -# completions -fpath=(/usr/local/share/zsh-completions $fpath) +# completions. Homebrew keeps them under its own prefix, which differs by +# machine -- /opt/homebrew on Apple Silicon, /usr/local on Intel -- and formulae +# install into share/zsh/site-functions, not the share/zsh-completions this +# hardcoded until 2026-09-21. That path existed on neither Mac, so every +# brew-installed completion (_brew, _bat, _deno, ...) was silently missing. +# Probed rather than asked of `brew --prefix`, which would fork on every shell, +# and done here because compinit below is the only moment fpath is read. +for _fp in \ + "${HOMEBREW_PREFIX:-/opt/homebrew}/share/zsh/site-functions" \ + "${HOMEBREW_PREFIX:-/opt/homebrew}/share/zsh-completions" \ + /usr/local/share/zsh/site-functions \ + /usr/local/share/zsh-completions +do + [[ -d "$_fp" ]] && fpath=("$_fp" $fpath) +done +unset _fp # fix delete bindkey "^[[3~" delete-char |
