From 0b183f8acdb494f42228615ec61c5e7ee11fed29 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 23 Feb 2024 01:24:01 +0000 Subject: [PATCH] fix(zsh/completion): ensure brew and brew installed shell completion works --- zshenv | 14 +++++++++----- zshrc | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/zshenv b/zshenv index d253d9f..a1f9f67 100644 --- a/zshenv +++ b/zshenv @@ -137,19 +137,23 @@ if command-exists brew; then brew-prefix() { local package="$1" + local cachekey + cachekey="$package" if [[ -z "$package" ]]; then - package="__none__" + cachekey="__none__" fi - if [[ -n "${_brew_prefix_cache[$package]}" ]]; then - echo "${_brew_prefix_cache[$package]}" + if [[ -n "${_brew_prefix_cache[$cachekey]}" ]]; then + echo "${_brew_prefix_cache[$cachekey]}" else local result=$(brew --prefix "$package") - _brew_prefix_cache[$package]=$result - echo $result + _brew_prefix_cache["$cachekey"]="$result" + echo "$result" fi } + + export BREW_SITEFUNS="$(brew-prefix)/share/zsh/site-functions" fi # Linuxbrew diff --git a/zshrc b/zshrc index e0654b2..72804b7 100644 --- a/zshrc +++ b/zshrc @@ -66,6 +66,10 @@ zstyle ':completion:*:make:*' tag-order targets if [ -d "$ZSH_COMPLETIONS" ]; then fpath=("$ZSH_COMPLETIONS" $fpath); fi if [ -d "$DOTZSH_SITEFUNS" ]; then fpath=("$DOTZSH_SITEFUNS" $fpath); fi +if [ -d "$BREW_SITEFUNS" ]; then fpath=("$BREW_SITEFUNS" $fpath); fi + +autoload -Uz compinit +compinit # setup-completions is a helper function to setup completions for a given # command. It takes the command name, the source of the completion, and the