Tags: code
Homebrew, a popular package manager for macOS and Linux, simplifies software installation, management, and removal. It’s known for its ease of use and extensive library of packages, called “formulae” (core packages and CLI tools) and “casks” (GUI applications). Here are some of the cool things about Homebrew:
- Easy Installation: With Homebrew, you can install software and development tools with just one command. No more fussing around!
- Takes Care of Dependencies: Homebrew automatically takes care of all the software dependencies, so you don’t have to worry about missing any important libraries.
- Lightweight: Homebrew installs packages to their own directory and
then symlinks their files into
/opt/homebrew
(on Apple Silicon). - Community-Driven: Thousands of open-source contributors are always working on Homebrew, making sure that the packages are up-to-date and super secure.
- Extensible with Casks: Homebrew Cask lets you manage GUI
applications. Just type
brew install —cask firefox
and you’re good to go!
Commands
- Updating homebrew on macOS:
brew update
- Verifying the update:
brew --version
- Upgrading installed packages:
brew upgrade
- Cleaning up unused files:
brew cleanup
- Listing installed packages:
brew list
- Checking the version of pandoc installed via homebrew:
brew info pandoc
- Force Reinstall:
brew reinstall obsidian
Automate Homebrew Commands
#!/bin/bash
set -e # Exit immediately if a command fails
start_time=$(date +%s)
echo "🔍 Checking for Homebrew updates…"
brew update
# Capture outdated package list
outdated=$(brew outdated)
if [[ -z "$outdated" ]]; then
echo "✅ No outdated formulas found. Your system is up to date!"
else
echo "📋 Outdated formulas found:"
echo "$outdated"
read -p "⚠️ Upgrade all formulas and casks? (y/n) " choice
if [[ "$choice" =~ ^[Yy]$ ]]; then
echo "⬆️ Upgrading formulas and casks…"
brew upgrade && brew upgrade --cask
echo "🧹 Running cleanup…"
brew cleanup
else
echo "🚫 Upgrade canceled."
exit 0
fi
fi
elapsed_time=$(( $(date +%s) - start_time ))
echo "✅ Homebrew maintenance completed in $elapsed_time seconds!"
Also 2025-03-17: Package Managers