all repos — dot @ d312cb2acca4cff77c82ea4467585e0a2814c47c

Shell, editor and terminal configuration, and the tools that go with them

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.
Igor Soarez igor@soarez.org
Mon, 21 Sep 2026 15:26:23 +0300
commit

d312cb2acca4cff77c82ea4467585e0a2814c47c

parent

73031b778fa3460181be045bf06587917c13ebd5

1 files changed, 16 insertions(+), 2 deletions(-)

jump to
M config/zshrc → config/zshrc

@@ -12,8 +12,22 @@

# 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