Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@l50
Last active March 21, 2021 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l50/884919db8c6819e73ebe2f50c6928fcc to your computer and use it in GitHub Desktop.
Save l50/884919db8c6819e73ebe2f50c6928fcc to your computer and use it in GitHub Desktop.
Automate Brew Updates with launchd for a particular user
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# brew.sh
#
# Script to automate brew updates
#
# Usage: bash brew.sh
#
# Author: Jayson Grace, https://techvomit.net
# ----------------------------------------------------------------------------
brew update
brew upgrade
brew cleanup
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:</string>
</dict>
<key>Label</key>
<string>domainextension.site.usernamegoeshere-brew</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<string>/Users/usernamegoeshere/Library/LaunchAgents/brew.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>16</integer>
</dict>
</dict>
</plist>
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# setup.sh
#
# Dumb setup script for the automated brew updates work
# that assumes the files that it's moving into place are in the same
# directory as this script when it is run.
#
# Usage: bash setup.sh
#
# Author: Jayson Grace, https://techvomit.net
# ----------------------------------------------------------------------------
mv brew.sh ~/Library/LaunchAgents
mv domainextension.site.usernamegoeshere.autobrew.plist ~/Library/LaunchAgents
chmod +x ~/Library/LaunchAgents/brew.sh
launchctl load ~/Library/LaunchAgents/domainextension.site.usernamegoeshere.autobrew.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment