Skip to content

Instantly share code, notes, and snippets.

@loop
Created July 25, 2017 18:35
Show Gist options
  • Save loop/f994057d6dee5ba0d33ae7278482e97d to your computer and use it in GitHub Desktop.
Save loop/f994057d6dee5ba0d33ae7278482e97d to your computer and use it in GitHub Desktop.
whatsnew
#!/bin/sh
# up - script to keep your Mac up-to-date (both OS and Homebrew updates) via the command line
# run thus to to install: cd /usr/local/bin && curl -s -O https://gist.githubusercontent.com/mayel/e681a6175bf17366a16e03006d7feac2/raw/bb4ddb0c4842f5633fa1f29df61c433760c4affe/up && chmod 755 /usr/local/bin/up
# and then run it anytime by simply entering the command: up
# By https://github.com/mayel based on a script by https://github.com/imwally
# homebrew
echo "Checking homebrew packages..."
brew update > /dev/null;
new_packages=$(brew outdated --quiet)
num_packages=$(echo $new_packages | wc -w)
if [ $num_packages -gt 0 ]; then
echo "\n$num_packages New brew updates available:"
for package in $new_packages; do
echo " * $package";
done
echo "\nInstall brew updates? (y/n)"
read answer
if echo "$answer" | grep -iq "^y" ; then
brew upgrade && echo "\nBrew updates done!"
fi
echo "\nClean up old versions of brew packages? (y/n)"
read answer
if echo "$answer" | grep -iq "^y" ; then
brew cleanup && echo "\nBrew cleanup done!"
fi
else
echo "\nNo brew updates available."
fi
# macOS
echo "\nChecking macOS updates..."
softwareupdate -l | tail +5
echo "\nInstall macOS updates? (y/n)"
read answer
if echo "$answer" | grep -iq "^y" ; then
sudo softwareupdate -i -a && echo "\nmacOS updates done! You may need to reboot..."
fi
@loop
Copy link
Author

loop commented Jul 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment