What This Script Does

The auto-update-brew-hybrid.sh script is the most fully-featured auto-update option in the Brew Scripts toolkit. It performs the same core Homebrew maintenance operations as the basic auto-update script — updating the package index, upgrading installed packages, and cleaning up old versions — but adds a comprehensive dual-notification system that keeps you informed through both email and text message.

The hybrid approach to notifications addresses a common trade-off. Text messages are great for quick, at-a-glance status updates that you can read in seconds, but they are not ideal for detailed information. Email, on the other hand, can accommodate a full report with all the technical details you might want to review, but emails are easy to miss or ignore if you are not checking your inbox regularly. By sending both, this script ensures you get the quick notification via text and the detailed report via email, covering both use cases.

The email report is the more substantial of the two notifications. It is an HTML message with a success or warning heading, counts of successful operations, errors, packages updated and applications updated, a line for each step (update, package upgrade, cask upgrade, cleanup), and the last 20 lines of the log.

The text message is deliberately brief: one line with a success or issues marker and the operation, package and app counts. You can read it on your lock screen and open the email or log only if something went wrong.

Email is sent with the command-line mail -s command, which hands the message to macOS's built-in postfix mail system. It does not use the Mail app. macOS ships postfix switched off, so email only works once you have configured postfix with an SMTP relay. Before sending, the script checks that the mail system is running; if it is not, it logs "Email NOT sent" and carries on, so without a relay no email reports are delivered. Text messages are sent by AppleScript telling the Messages app to send an iMessage to PHONE_NUMBER. That needs Messages signed in to iMessage and your terminal allowed to control Messages in System Settings > Privacy & Security > Automation. If the send fails, the script logs the error and continues.

Before updating, the script checks two conditions. It must be connected to the Wi-Fi network named in WIFI_NETWORK; it retries that check up to 3 times, 5 minutes apart. And the Mac must be on AC power. If either check fails, the script sends a "Skipped" text and email and exits without updating.

Everything is logged to ~/Library/Logs/AutoUpdateBrewHybrid.log, so the record survives even if both notification channels fail.

Usage

This script can be run manually or scheduled for automatic execution. Set WIFI_NETWORK, EMAIL_ADDRESS and PHONE_NUMBER at the top of the script first (the scheduling script fills in the email and phone for you).

# Preview what would be updated and how notifications would be sent
./auto-update-brew-hybrid.sh --dry-run

# Run the hybrid update with email and text notifications
./auto-update-brew-hybrid.sh

For automatic scheduling, use the Schedule Hybrid Updates script, which creates a launchd agent specifically configured to trigger this script on a recurring basis.

Options and Flags

Flag Description
--dry-run Check the Wi-Fi and power conditions and list outdated packages and casks, without upgrading anything, writing the log or sending any notifications. --check is an alias.

Configuration

There is no config file for this script. These values are hardcoded near the top of auto-update-brew-hybrid.sh; edit them there:

Setting Effect
EMAIL_ADDRESS Where detailed reports are sent. Delivery needs postfix configured with an SMTP relay (see above).
PHONE_NUMBER Your iMessage-compatible phone number for brief text message summaries. Include the country code.
WIFI_NETWORK The Wi-Fi network updates are allowed on. Edit WIFI_NETWORK at the top of the script; left as the placeholder, every run skips. There is no option to skip this check.

AC power is always required; there is no setting to turn that off. The two notification channels are independent: if one fails, the script logs the failure and still tries the other.

What Gets Changed

  • Homebrew packages — All installed formulae and casks are updated to their latest versions.
  • Old package versions — Previous versions of upgraded packages are removed to reclaim disk space.
  • Download cache — Cached installer files are cleared during the cleanup phase.
  • Email via mail — A detailed HTML report is handed to the local postfix mail system, which delivers it only if you have configured an SMTP relay.
  • iMessage via Messages — A one-line summary is sent through the Messages app.
  • Log file — Every run is appended to ~/Library/Logs/AutoUpdateBrewHybrid.log.

Related Scripts

  • Auto-Update (Basic) — A simpler version that sends only text message notifications. Choose this if you do not need email reports or want to keep things minimal.
  • Schedule Hybrid Updates — Creates a launchd agent to run this hybrid update script automatically on a schedule you define.