Skip to content

Instantly share code, notes, and snippets.

@Leask
Last active January 10, 2020 22:34
Show Gist options
  • Save Leask/f6c139364c3511b4c203f784a674b66c to your computer and use it in GitHub Desktop.
Save Leask/f6c139364c3511b4c203f784a674b66c to your computer and use it in GitHub Desktop.
Updating brew packages.
# Flora Up by LeaskH.com
up() {
echo 'Updating brew packages...'
brew update
brew upgrade --all
brew cleanup
echo ':) Done'
}
timestamp() {
date +%s
}
up_set() {
echo `timestamp` > /tmp/flora_up_at
}
up_get() {
upAt="`cat /tmp/flora_up_at 2> /dev/null`"
if [ "$upAt" = '' ]; then
echo 0;
else
echo $upAt;
fi
}
up_auto() {
((timdDiff=`timestamp`-`up_get`))
((maxDiff=60*60*24))
if [ $timdDiff -gt $maxDiff ]; then
up_set
up
fi
}
up_auto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment