mauvehed's dotfiles for personal and work environments
at main 40 lines 920 B view raw
1#!/bin/bash 2 3# Function to check the status of the last executed command 4check_status() { 5 if [ $? -ne 0 ]; then 6 echo "Error: $1 failed." 7 exit 1 8 fi 9} 10 11# Check if Homebrew is installed 12if ! command -v brew &>/dev/null; then 13 echo "Error: Homebrew is not installed. Please install Homebrew first." 14 exit 1 15fi 16 17# Update Homebrew 18echo "Updating Homebrew..." 19brew update 20check_status "brew update" 21 22# Upgrade all installed formulae 23echo "Upgrading installed formulae..." 24brew upgrade 25check_status "brew upgrade" 26 27# Upgrade all installed casks 28echo "Upgrading installed casks..." 29casks=$(brew list --cask) 30if [ -z "$casks" ]; then 31 echo "No casks installed. Skipping cask upgrades." 32else 33 for cask in $casks; do 34 echo "Upgrading cask: $cask" 35 brew upgrade --cask "$cask" 36 check_status "brew upgrade --cask $cask" 37 done 38fi 39 40echo "All upgrades completed successfully."