Make homebrew initialization more general

This commit is contained in:
lachtan
2022-09-30 18:46:24 +02:00
parent 066058234b
commit 97d61bc9bc

View File

@@ -1,5 +1,22 @@
nop ${BREW_HOME:=/home/linuxbrew}
nop ${BREW:="$BREW_HOME/.linuxbrew/bin/brew"}
# Homebrew initialization
# Can set BREW_HOME in advance
BREW_LOCATIONS=( \
"$HOME/.local/share/linuxbrew" \
"$HOME/.linuxbrew" \
"/home/linuxbrew/.linuxbrew" \
)
if [[ ! -d "$BREW_HOME" ]]; then
for brew_path in "${BREW_LOCATIONS[@]}"; do
if [[ -d "$brew_path" ]]; then
BREW_HOME="$brew_path"
break
fi
done
fi
BREW="$BREW_HOME/bin/brew"
if [[ -e "$BREW" ]]; then
path_backup="$PATH"
@@ -9,3 +26,4 @@ if [[ -e "$BREW" ]]; then
append_path "$HOMEBREW_PREFIX/bin"
append_path "$HOMEBREW_PREFIX/sbin"
fi