Skip to content

Instantly share code, notes, and snippets.

@tfeldmann
Last active November 24, 2024 16:59
Show Gist options
  • Save tfeldmann/ee7e81708d7926454867bd0a7e7b916d to your computer and use it in GitHub Desktop.
Save tfeldmann/ee7e81708d7926454867bd0a7e7b916d to your computer and use it in GitHub Desktop.
Update all pip packages, brew and brew casks (macOS) and backup a list of the installed software
#!/bin/sh
set -e
PIP=pip3
scriptdir=$(dirname "$0")
listsdir="$scriptdir/lists"
mkdir -p "$listsdir"
echo "Update all python packages..."
$PIP list --local -o --format=freeze | cut -d = -f 1 | xargs $PIP install -U
$PIP list --local --format=freeze > "$listsdir/pip_list.txt"
echo "Update pipx apps..."
pipx upgrade-all
pipx list > "$listsdir/pipx_list.txt"
echo "Update homebrew..."
brew update
brew upgrade
brew list > "$listsdir/brew_list.txt"
echo "Update all brew casks..."
brew cask outdated | cut -d " " -f 1 | xargs -n 1 brew cask reinstall
brew cask list > "$listsdir/brew_cask_list.txt"
echo "Cleanup..."
brew cleanup --prune=0
@captahole
Copy link

I revised this to remove the errors for outdated brew commands.
#!/bin/sh
set -e

PIP=pip3

scriptdir=$(dirname "$0")
listsdir="$scriptdir/lists"
mkdir -p "$listsdir"

echo "Update all python packages..."
for line in $(pip3 list --local --format=freeze); do
package=${line%%=*}
$PIP install -U $package
done

echo "Update pipx apps..."
pipx upgrade-all
pipx list > "$listsdir/pipx_list.txt"

echo "Update homebrew..."
brew update
brew upgrade
brew list > "$listsdir/brew_list.txt"

echo "Update all brew casks..."
brew list --cask | xargs brew upgrade --cask --greedy
brew list --cask > "$listsdir/brew_cask_list.txt"

echo "Cleanup..."
brew cleanup --prune=0

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