Last active
September 26, 2020 03:32
-
-
Save divspace/fdd9d374a74399191c67 to your computer and use it in GitHub Desktop.
A bash script macOS to keep Homebrew, Mac App Store, Composer, and npm updated (including globally installed packages)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
################################################################################ | |
# Place this script wherever you like and create an alias (.zshrc or .bashrc): | |
# | |
# alias update='sh ~/Scripts/update.sh' | |
# | |
# Then just run `update` to update: | |
# | |
# - Homebrew | |
# - Mac App Store apps (if you have the Mac App Store CLI installed) | |
# - Composer, npm, and respective globally installed packages | |
# | |
# https://gist.githubusercontent.com/divspace/fdd9d374a74399191c67 | |
################################################################################ | |
sudo -v | |
while true; do | |
sudo -n true | |
sleep 60 | |
kill -0 "$$" || exit | |
done 2>/dev/null & | |
if [ $(command -v brew) ]; then | |
if [ ! -d /Library/Caches/Homebrew/Casks ]; then | |
mkdir -p /Library/Caches/Homebrew/Casks | |
fi | |
brew update --force | |
brew upgrade | |
brew cleanup | |
brew doctor | |
fi | |
if [ $(command -v mas) ] && [ ! -z $(mas outdated) ]; then | |
mas upgrade | |
fi | |
if [ $(command -v composer) ]; then | |
composer self-update | |
composer global update | |
fi | |
if [ $(command -v npm) ]; then | |
npm update -g | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment