From 83e4be78ac029cf6504deeff6f4ede5aaaab1a8a Mon Sep 17 00:00:00 2001 From: Jerry Chae Date: Wed, 13 May 2026 22:18:20 +0900 Subject: [PATCH] =?UTF-8?q?brew=20=EC=84=A4=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install-lazygit.sh | 33 +++++++++++++++++++++++++++------ install-pi.sh | 28 ++++++++++++++++++++++------ install-tmux.sh | 29 +++++++++++++++++++++++------ 3 files changed, 72 insertions(+), 18 deletions(-) diff --git a/install-lazygit.sh b/install-lazygit.sh index 6f121ce..d6ceebe 100644 --- a/install-lazygit.sh +++ b/install-lazygit.sh @@ -30,6 +30,30 @@ error() { } success() { echo "[OK] $*" >&2; } +# ──────────────────────────────────────────── +# Ensure Homebrew is available on macOS +# ──────────────────────────────────────────── +ensure_brew() { + if command -v brew &>/dev/null; then + return 0 + fi + info "Homebrew is not installed. Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + if [ -d /opt/homebrew/bin ]; then + export PATH="/opt/homebrew/bin:$PATH" + fi + if [ -d /usr/local/bin ]; then + export PATH="/usr/local/bin:$PATH" + fi + command -v brew &>/dev/null || error "Homebrew installation failed. Install it manually: https://brew.sh/" + success "Homebrew installed" +} +error() { + echo "[ERROR] $*" >&2 + exit 1 +} +success() { echo "[OK] $*" >&2; } + # ──────────────────────────────────────────── # Check for git (required by lazygit) # ──────────────────────────────────────────── @@ -37,12 +61,9 @@ if ! command -v git &>/dev/null; then info "git is not installed. Installing git..." case "$(uname -s)" in Darwin) - if command -v brew &>/dev/null; then - brew install -y git - success "git installed via Homebrew" - else - error "Homebrew (brew) is required to install git on macOS. Install it from https://brew.sh/" - fi + ensure_brew + brew install -y git + success "git installed via Homebrew" ;; Linux) if command -v apt-get &>/dev/null; then diff --git a/install-pi.sh b/install-pi.sh index 928f6c8..13c60c7 100755 --- a/install-pi.sh +++ b/install-pi.sh @@ -51,6 +51,25 @@ error() { } success() { echo "[OK] $*" >&2; } +# ──────────────────────────────────────────── +# Ensure Homebrew is available on macOS +# ──────────────────────────────────────────── +ensure_brew() { + if command -v brew &>/dev/null; then + return 0 + fi + info "Homebrew is not installed. Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + if [ -d /opt/homebrew/bin ]; then + export PATH="/opt/homebrew/bin:$PATH" + fi + if [ -d /usr/local/bin ]; then + export PATH="/usr/local/bin:$PATH" + fi + command -v brew &>/dev/null || error "Homebrew installation failed. Install it manually: https://brew.sh/" + success "Homebrew installed" +} + # ──────────────────────────────────────────── # Check required commands # ──────────────────────────────────────────── @@ -63,12 +82,9 @@ if ! command -v npm &>/dev/null; then info "npm is not installed. Installing Node.js..." case "$OS" in Darwin) - if command -v brew &>/dev/null; then - brew install node - success "Node.js installed via Homebrew" - else - error "Homebrew (brew) is required to install Node.js on macOS. Install it from https://brew.sh/" - fi + ensure_brew + brew install node + success "Node.js installed via Homebrew" ;; Linux) if command -v apt-get &>/dev/null; then diff --git a/install-tmux.sh b/install-tmux.sh index cd2a1b5..dea7545 100755 --- a/install-tmux.sh +++ b/install-tmux.sh @@ -43,6 +43,26 @@ Darwin | Linux) ;; ;; esac +# ──────────────────────────────────────────── +# Ensure Homebrew is available on macOS +# ──────────────────────────────────────────── +ensure_brew() { + if command -v brew &>/dev/null; then + return 0 + fi + info "Homebrew is not installed. Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + # Add brew to PATH for Apple Silicon + if [ -d /opt/homebrew/bin ]; then + export PATH="/opt/homebrew/bin:$PATH" + fi + if [ -d /usr/local/bin ]; then + export PATH="/usr/local/bin:$PATH" + fi + command -v brew &>/dev/null || error "Homebrew installation failed. Install it manually: https://brew.sh/" + success "Homebrew installed" +} + info "Platform: $OS ($ARCH)" # ──────────────────────────────────────────── @@ -56,12 +76,9 @@ if command -v tmux &>/dev/null; then else case "$OS" in Darwin) - if command -v brew &>/dev/null; then - brew install -y tmux - success "tmux installed via Homebrew" - else - error "Homebrew (brew) is required on macOS. Install it from https://brew.sh/" - fi + ensure_brew + brew install tmux + success "tmux installed via Homebrew" ;; Linux) if command -v apt-get &>/dev/null; then