Skip to content

Instantly share code, notes, and snippets.

@Neko-Design
Created July 2, 2026 10:01
Show Gist options
  • Select an option

  • Save Neko-Design/c3411a0dc7e6431c10aee309f0fd4a6f to your computer and use it in GitHub Desktop.

Select an option

Save Neko-Design/c3411a0dc7e6431c10aee309f0fd4a6f to your computer and use it in GitHub Desktop.
Homebrew auto-update profile script
#!/bin/bash
# Check for the existance of ~/.brewlastupgraded containing a unix timestamp of the last upgrade
if [ -f ~/.brewlastupgraded ]; then
lastupgraded=$(cat ~/.brewlastupgraded)
else
lastupgraded=0
fi
# Check if the last upgrade was more than 7 days ago
if [ $(date +%s) -gt $((lastupgraded + 7*24*60*60)) ]; then
echo "It's been more than 7 days since the last brew upgrade. Upgrading now..."
brew update && brew upgrade
# Update the last upgraded timestamp
date +%s > ~/.brewlastupgraded
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment