mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-22 15:08:01 +00:00
completion: Detect Homebrew prefix internally, not idiomatically
For performance reasons, we prefer detecting Homebrew prefix internally
instead of the more idiomatic form `brew --prefix`.
We attempt looking up $HOMEBREW_PREFIX or $HOMEBREW_REPOSITORY first (in
case `brew shellenv` has been sourced-in earlier). Else, we look it up
by resolving absolute path of $HOMEBREW_REPOSITORY. $HOMEBREW_PREFIX is
same as $HOMEBREW_REPOSITORY except when Homebrew is installed in
'/usr/local' ($HOMEBREW_REPOSITORY == '/usr/local/Homebrew'). This is
usually the case for Intel Macs.
This should work for most standard (and officially documented) Homebrew
installations.
For implementation details in Homebrew,
see: 2a850e02d8/bin/brew (L62-L70)
Co-authored-by: mattmc3 <mattmc3@gmail.com>
This commit is contained in:
parent
2c66331316
commit
ac1c39d2e1
@ -14,12 +14,16 @@ fi
|
|||||||
# Add zsh-completions to $fpath.
|
# Add zsh-completions to $fpath.
|
||||||
fpath=(${0:h}/external/src $fpath)
|
fpath=(${0:h}/external/src $fpath)
|
||||||
|
|
||||||
# Add completion for keg-only brewed curl when available.
|
# Add completion for keg-only brewed curl on macOS when available.
|
||||||
if (( $+commands[brew] )) \
|
if (( $+commands[brew] )); then
|
||||||
&& [[ -d "${curl_prefix::="$(brew --prefix 2> /dev/null)"/opt/curl}" ]]; then
|
brew_prefix=${HOMEBREW_PREFIX:-${HOMEBREW_REPOSITORY:-$commands[brew]:A:h:h}}
|
||||||
fpath=($curl_prefix/share/zsh/site-functions $fpath)
|
# $HOMEBREW_PREFIX defaults to $HOMEBREW_REPOSITORY but is explicitly set to
|
||||||
|
# /usr/local when $HOMEBREW_REPOSITORY is /usr/local/Homebrew.
|
||||||
|
# https://github.com/Homebrew/brew/blob/2a850e02d8f2dedcad7164c2f4b95d340a7200bb/bin/brew#L66-L69
|
||||||
|
[[ $brew_prefix == '/usr/local/Homebrew' ]] && brew_prefix=$brew_prefix:h
|
||||||
|
fpath=($brew_prefix/opt/curl/share/zsh/site-functions(/N) $fpath)
|
||||||
|
unset brew_prefix
|
||||||
fi
|
fi
|
||||||
unset curl_prefix
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Options
|
# Options
|
||||||
|
Loading…
Reference in New Issue
Block a user