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 includes a complete list of every package that was updated, with both the old and new version numbers. If any packages failed to update, the error messages are included so you can diagnose the issue. The report also shows the total number of packages on your system, how many were outdated before the update, how many were successfully upgraded, and how much disk space was recovered during the cleanup phase. This level of detail makes it easy to audit your system's update history over time.

The text message notification is deliberately brief. It provides a one-line summary with the total number of packages updated and a pass/fail status indicator. If there were any errors, the text mentions that details are available in the email. This design means you can glance at the text on your phone's lock screen and immediately know whether everything went smoothly, without needing to read through a full report unless you want to.

Email delivery uses the macOS built-in Mail app via AppleScript. This means you do not need to configure an SMTP server, install any third-party email tools, or manage API keys for an email service. The script simply tells Mail.app to compose and send a message to your configured email address. The only prerequisite is that Mail.app is set up with at least one email account, which is the case for most Mac users. Text message delivery uses the same iMessage integration as the basic auto-update script, communicating with the Messages app through AppleScript.

Like all auto-update scripts in the toolkit, the hybrid version performs pre-flight checks before running. It verifies that your Mac is connected to the correct Wi-Fi network and optionally checks that AC power is connected. If either condition is not met, the script exits gracefully and logs the reason for skipping. This prevents unwanted updates from running on metered connections or draining your battery during a portable work session.

The script produces detailed logs that complement the email and text notifications. Even if both notification channels fail for some reason, the log file at ~/Library/Logs/ captures every detail of the update run. Each log entry includes a timestamp and severity level, making it straightforward to trace through the sequence of events and identify where any problems occurred.

Usage

This script can be run manually or scheduled for automatic execution. Make sure both your email and phone number are configured in the config file for full notification support.

# 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 Simulate the entire update and notification process. Shows which packages would be updated and previews the email and text message content without sending anything.

Configuration

This script uses the most configuration settings of any script in the toolkit. Make sure the following are set in your config/homebrew-scripts.conf file:

Setting Effect
EMAIL_ADDRESS The email address where detailed update reports are sent. Must be reachable from an account configured in Mail.app.
PHONE_NUMBER Your iMessage-compatible phone number for brief text message summaries. Include the country code.
WIFI_NETWORK The name of your preferred Wi-Fi network. Updates only run when connected to this network. Leave empty to skip the network check.
REQUIRE_AC_POWER When set to true, updates only run when the Mac is connected to AC power.

If EMAIL_ADDRESS is not configured, the script still runs updates and sends the text message, but skips the email report. Similarly, if PHONE_NUMBER is not set, the text message is skipped but the email is still sent. Both notification channels operate independently.

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.app — A detailed update report is composed and sent using the macOS Mail application. The email appears in your sent folder in Mail.app.
  • iMessage via Messages.app — A brief summary text message is sent through the macOS Messages application.
  • Log file — A comprehensive log is created at ~/Library/Logs/ with full details of every operation performed.

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.