#! /usr/bin/env bash # Defines software installer functions. # Label: Install Homebrew # Description: Install and setup Homebrew. install_homebrew() { if ! command -v brew > /dev/null; then /bin/bash -c "$(curl --location --fail --silent --show-error https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # Determine Homebrew path based on architecture local brew_path="/opt/homebrew/bin/brew" if [[ "$(/usr/bin/arch)" != "arm64" ]]; then brew_path="/usr/local/bin/brew" fi # Add to shell profile for future sessions if [[ ! -f "$HOME/.zprofile" ]] || ! grep -q "brew shellenv" "$HOME/.zprofile"; then echo >> "$HOME/.zprofile" echo "eval \"\$($brew_path shellenv)\"" >> "$HOME/.zprofile" fi # Set up PATH for current session eval "$($brew_path shellenv)" fi } export -f install_homebrew