Last active
August 3, 2022 16:46
-
-
Save sp4ce/12503043453f3790aa72916639121256 to your computer and use it in GitHub Desktop.
Brew outdated notification
This file contains 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
# brew outdated notification | |
BREW_OUTDATED_CHECK_TIME=$(cat ~/.brew-outdated-check-time 2>/dev/null) | |
if [[ -z "${BREW_OUTDATED_CHECK_TIME}" || $(($BREW_OUTDATED_CHECK_TIME + 64800)) -le $(date +%s) ]]; then | |
date +%s >| ~/.brew-outdated-check-time | |
echo "Checking outdated brew formulae..." | |
if [[ -n "${BREW_OUTDATED_CHECK_TIME}" ]]; then | |
echo "It was previously checked on $(date -r $BREW_OUTDATED_CHECK_TIME)" | |
fi | |
brew update --quiet | |
outdated=$(brew outdated --quiet) | |
pinned=$(brew list --pinned) | |
# Remove pinned formulae from the list of outdated formulae | |
outdated=$(comm -1 -3 <(echo "${pinned}") <(echo "${outdated}")) | |
if [[ -n "${outdated}" ]]; then | |
# join lines together with ", " and remove possible trailing comma character | |
outdated=$(perl -pe 's/\n/, /g' <(echo "${outdated}") | sed 's/, $//g') | |
printf "The following formulae are outdated:\n${outdated}\n" | |
else | |
echo "No outdated formulae" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment