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.
This commit is contained in:
Conlan Cesar 2024-10-07 14:11:02 -04:00 committed by Ruoyu Zhong
parent aba44a4b7a
commit f7b8681bc9
No known key found for this signature in database

View File

@ -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