2 # brew-run -- Update, upgrade, and clean up Hoembrew installation.
4 # Include "ax-common.sh":
6 for dir in "$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr; do
7 [ -z "$ax_common_sourced" ] || break
8 ax_common="${dir}/lib/ax/ax-common.sh"
9 # shellcheck source=/usr/local/lib/ax/ax-common.sh
10 [ -r "$ax_common" ] && . "$ax_common"
12 if [ -z "$ax_common_sourced" ]; then
13 ax_msg() { shift; echo "$@"; }
14 ax_abort() { ax_msg - "$@"; exit 1; }
16 unset dir ax_common ax_common_sourced
18 ax_msg - "Updating Homebrew installation ..."
19 brew update || ax_abort "Update failed!"
21 outdated=$( brew outdated --quiet | wc -l | tr -d '\t ' )
22 if [ $outdated -gt 0 ]; then
24 ax_msg - "$outdated formula outdated:"
25 brew outdated || ax_abort "Failed to list outdated packages!"
28 brew upgrade --all || ax_abort "Upgrade failed!"
29 brew linkapps --local || ax_abort "Linking of applications failed!"
32 brew cleanup || ax_abort "\"brew cleanup\" failed!"
33 brew prune || ax_abort "\"brew prune\" failed!"
35 ax_msg 0 "Nothing outdated."