From f7b8681bc95db17bea12ff7d12c179d57b890246 Mon Sep 17 00:00:00 2001 From: Conlan Cesar Date: Mon, 7 Oct 2024 14:11:02 -0400 Subject: [PATCH] Add zsh site-functions to `fpath` I considered doing a fallthough in the case-statement, but that doesn't work on bash leq 4 (notably, those versions shipped with MacOS by default). I chose to prepend the value to the array to mirror the homebrew completion [instructions page](https://docs.brew.sh/Shell-Completion). I also chose to leave off the `-d`irectory check -- zsh seems to tolerate invalid paths, so there isn't much harm in adding it anyway. I'm flexible on any of these choices should someone feel strongly. However, I imagine this is the best combination given the trade-offs we have. --- Library/Homebrew/cmd/shellenv.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/cmd/shellenv.sh b/Library/Homebrew/cmd/shellenv.sh index 8634b65daf..498510ac44 100644 --- a/Library/Homebrew/cmd/shellenv.sh +++ b/Library/Homebrew/cmd/shellenv.sh @@ -81,6 +81,10 @@ homebrew-shellenv() { echo "export HOMEBREW_PREFIX=\"${HOMEBREW_PREFIX}\";" echo "export HOMEBREW_CELLAR=\"${HOMEBREW_CELLAR}\";" echo "export HOMEBREW_REPOSITORY=\"${HOMEBREW_REPOSITORY}\";" + if [[ "${HOMEBREW_SHELL_NAME}" == "zsh" ]] || [[ "${HOMEBREW_SHELL_NAME}" == "-zsh" ]] + then + echo "fpath[1,0]=\"${HOMEBREW_PREFIX}/share/zsh/site-functions\";" + fi if [[ -n "${PATH_HELPER_ROOT}" ]] then PATH_HELPER_ROOT="${PATH_HELPER_ROOT}" PATH="${HOMEBREW_PATH}" /usr/libexec/path_helper -s