2019-01-30 21:31:33 +00:00
|
|
|
#: * `shellenv`
|
2018-09-13 09:27:43 +01:00
|
|
|
#:
|
2019-08-20 00:04:14 -04:00
|
|
|
#: Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`.
|
2018-09-13 09:27:43 +01:00
|
|
|
#:
|
2019-08-20 00:04:14 -04:00
|
|
|
#: The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
|
2021-08-03 18:40:59 +08:00
|
|
|
#: The variable `HOMEBREW_SHELLENV_PREFIX` will be exported to avoid adding duplicate entries to the environment variables.
|
2021-08-27 14:39:29 +08:00
|
|
|
#:
|
|
|
|
#: Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`)
|
|
|
|
#: with: `eval "$(/path/to/brew shellenv)"`.
|
|
|
|
#:
|
|
|
|
#: The variable `HOMEBREW_SHELLENV_PREFIX` may be inherited from the parent shell session. If you explicitly
|
|
|
|
#: modified the path variables (e.g. `PATH`) in your dotfiles which breaks the subshell varibale inheritecement,
|
|
|
|
#: please use `eval "$(HOMEBREW_SHELLENV_PREFIX='' /path/to/brew shellenv)"` to always get all the export statements.
|
2018-09-13 09:27:43 +01:00
|
|
|
|
2021-04-28 20:47:39 +09:00
|
|
|
# HOMEBREW_CELLAR and HOMEBREW_PREFIX are set by extend/ENV/super.rb
|
|
|
|
# HOMEBREW_REPOSITORY is set by bin/brew
|
|
|
|
# shellcheck disable=SC2154
|
2018-09-13 09:27:43 +01:00
|
|
|
homebrew-shellenv() {
|
2021-08-27 14:39:29 +08:00
|
|
|
if [[ "${HOMEBREW_SHELLENV_PREFIX}" == "${HOMEBREW_PREFIX}" ]]; then
|
|
|
|
[[ "$(PATH="${HOMEBREW_PATH}" command -v brew)" == "${HOMEBREW_PREFIX}/bin/brew" ]] && return
|
|
|
|
opoo "You have set HOMEBREW_SHELLENV_PREFIX=\"${HOMEBREW_SHELLENV_PREFIX}\"," \
|
2021-08-27 18:22:01 +08:00
|
|
|
"but the brew's executable is not present in your PATH." \
|
2021-08-27 14:39:29 +08:00
|
|
|
"Please run \`brew help shellenv\` for more information."
|
|
|
|
fi
|
2021-08-03 16:17:24 +08:00
|
|
|
|
2021-04-28 20:47:39 +09:00
|
|
|
case "$(/bin/ps -p "${PPID}" -c -o comm=)" in
|
2021-07-29 22:39:26 +08:00
|
|
|
fish | -fish)
|
2021-04-28 20:47:39 +09:00
|
|
|
echo "set -gx HOMEBREW_PREFIX \"${HOMEBREW_PREFIX}\";"
|
|
|
|
echo "set -gx HOMEBREW_CELLAR \"${HOMEBREW_CELLAR}\";"
|
|
|
|
echo "set -gx HOMEBREW_REPOSITORY \"${HOMEBREW_REPOSITORY}\";"
|
2021-08-03 16:17:24 +08:00
|
|
|
echo "set -gx HOMEBREW_SHELLENV_PREFIX \"${HOMEBREW_PREFIX}\";"
|
2021-04-28 20:47:39 +09:00
|
|
|
echo "set -q PATH; or set PATH ''; set -gx PATH \"${HOMEBREW_PREFIX}/bin\" \"${HOMEBREW_PREFIX}/sbin\" \$PATH;"
|
|
|
|
echo "set -q MANPATH; or set MANPATH ''; set -gx MANPATH \"${HOMEBREW_PREFIX}/share/man\" \$MANPATH;"
|
|
|
|
echo "set -q INFOPATH; or set INFOPATH ''; set -gx INFOPATH \"${HOMEBREW_PREFIX}/share/info\" \$INFOPATH;"
|
2019-02-20 10:10:31 +00:00
|
|
|
;;
|
2021-07-29 22:39:26 +08:00
|
|
|
csh | -csh | tcsh | -tcsh)
|
2021-04-28 20:47:39 +09:00
|
|
|
echo "setenv HOMEBREW_PREFIX ${HOMEBREW_PREFIX};"
|
|
|
|
echo "setenv HOMEBREW_CELLAR ${HOMEBREW_CELLAR};"
|
|
|
|
echo "setenv HOMEBREW_REPOSITORY ${HOMEBREW_REPOSITORY};"
|
2021-08-03 16:17:24 +08:00
|
|
|
echo "setenv HOMEBREW_SHELLENV_PREFIX ${HOMEBREW_PREFIX};"
|
2021-04-28 20:47:39 +09:00
|
|
|
echo "setenv PATH ${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:\$PATH;"
|
|
|
|
echo "setenv MANPATH ${HOMEBREW_PREFIX}/share/man\`[ \${?MANPATH} == 1 ] && echo \":\${MANPATH}\"\`:;"
|
|
|
|
echo "setenv INFOPATH ${HOMEBREW_PREFIX}/share/info\`[ \${?INFOPATH} == 1 ] && echo \":\${INFOPATH}\"\`;"
|
2019-02-20 10:10:31 +00:00
|
|
|
;;
|
|
|
|
*)
|
2021-04-28 20:47:39 +09:00
|
|
|
echo "export HOMEBREW_PREFIX=\"${HOMEBREW_PREFIX}\";"
|
|
|
|
echo "export HOMEBREW_CELLAR=\"${HOMEBREW_CELLAR}\";"
|
|
|
|
echo "export HOMEBREW_REPOSITORY=\"${HOMEBREW_REPOSITORY}\";"
|
2021-08-03 16:17:24 +08:00
|
|
|
echo "export HOMEBREW_SHELLENV_PREFIX=\"${HOMEBREW_PREFIX}\";"
|
2021-04-28 20:47:39 +09:00
|
|
|
echo "export PATH=\"${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin\${PATH+:\$PATH}\";"
|
|
|
|
echo "export MANPATH=\"${HOMEBREW_PREFIX}/share/man\${MANPATH+:\$MANPATH}:\";"
|
|
|
|
echo "export INFOPATH=\"${HOMEBREW_PREFIX}/share/info:\${INFOPATH:-}\";"
|
2019-02-20 10:10:31 +00:00
|
|
|
;;
|
|
|
|
esac
|
2018-09-13 09:27:43 +01:00
|
|
|
}
|