mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 07:06:40 +00:00
chore(zshenv): simplify brew-prefix helper function
This commit is contained in:
16
zshenv
16
zshenv
@@ -136,21 +136,13 @@ if command-exists brew; then
|
|||||||
typeset -A _brew_prefix_cache
|
typeset -A _brew_prefix_cache
|
||||||
|
|
||||||
brew-prefix() {
|
brew-prefix() {
|
||||||
local package="$1"
|
local package="${1:-__none__}"
|
||||||
local cachekey
|
|
||||||
|
|
||||||
cachekey="$package"
|
if [[ -z "${_brew_prefix_cache[$package]}" ]]; then
|
||||||
if [[ -z "$package" ]]; then
|
_brew_prefix_cache[$package]="$(brew --prefix "$1" || return $?)"
|
||||||
cachekey="__none__"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${_brew_prefix_cache[$cachekey]}" ]]; then
|
echo "${_brew_prefix_cache[$package]}"
|
||||||
echo "${_brew_prefix_cache[$cachekey]}"
|
|
||||||
else
|
|
||||||
local result=$(brew --prefix "$package")
|
|
||||||
_brew_prefix_cache["$cachekey"]="$result"
|
|
||||||
echo "$result"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export BREW_SITEFUNS="$(brew-prefix)/share/zsh/site-functions"
|
export BREW_SITEFUNS="$(brew-prefix)/share/zsh/site-functions"
|
||||||
|
|||||||
Reference in New Issue
Block a user