aboutsummaryrefslogtreecommitdiffstats
path: root/shlib/homebrew.sh
blob: a00ad735dc6d50d917e4fcc711e718ec0d2bd9d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# shellcheck shell=sh
[ -n "${DOTFILES_HOMEBREW_LOADED}" ] && return
readonly DOTFILES_HOMEBREW_LOADED=1

homebrew_is_installed() {
  command -v brew >/dev/null 2>&1
}

# Installs homebrew and verifies the installation.
#
# If the install was not successful, exits with a
# 1 status code.
homebrew_install() {
  /usr/bin/env bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  eval "$(/opt/homebrew/bin/brew shellenv)"
  if ! command -v brew >/dev/null 2>&1; then
    echo "Failed to install homebrew"
    return 1
  fi
}