Skip to content

Commit

Permalink
Recommend abbreviated multi-platform loader
Browse files Browse the repository at this point in the history
Co-authored-by: Mike McQuaid <[email protected]>
  • Loading branch information
colindean and MikeMcQuaid authored Feb 19, 2025
1 parent eab6e9f commit dfbc931
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions docs/Tips-N'-Tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,34 +148,6 @@ Use this to detect the likely Homebrew installation directory and load Homebrew
You may need to adapt this to your particular shell or other particulars of your environment.

```sh
# Execute only if brew isn't already available.
if ! [ -x "$(command -v brew)" ]; then
OS="$(uname)"
UNAME_MACHINE="$(uname -m)"
if [ "${OS}" = "Linux" ]; then
# Linux
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
elif [ "${OS}" = "Darwin" ]; then
if [ "${UNAME_MACHINE}" = "arm64" ]; then
# M-series ARM64 macOS
HOMEBREW_PREFIX="/opt/homebrew"
else
# Intel macOS
HOMEBREW_PREFIX="/usr/local"
fi
fi

if [ -d "${HOMEBREW_PREFIX}" ]; then
BREW_BIN="${HOMEBREW_PREFIX}/bin/brew"
if [ -x "${BREW_BIN}" ]; then
eval "\$(${BREW_BIN} shellenv)"
else
>&2 printf "Homebrew possibly found at %s but %s is not executable. Check the permissions.\n" "${HOMEBREW_PREFIX}" "${BREW_BIN}"
fi
else
>&2 printf "Homebrew not found where expected in %s on %s %s\n" "${HOMEBREW_PREFIX}" "${OS}" "${UNAME_MACHINE}"
>&2 printf "Double-check that it's installed or run the following command to install it\n\n\t%s\n" \
'/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
fi
fi
command -v brew || export PATH="/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/bin"
command -v brew && eval "$(brew shellenv)"
```

0 comments on commit dfbc931

Please sign in to comment.