Skip to content

Instantly share code, notes, and snippets.

@douglascayers
Last active August 16, 2026 22:29
Show Gist options
  • Select an option

  • Save douglascayers/c1c77a69823534d31acc0f9ccabca97b to your computer and use it in GitHub Desktop.

Select an option

Save douglascayers/c1c77a69823534d31acc0f9ccabca97b to your computer and use it in GitHub Desktop.
⚡️ Update various CLI tools
#!/usr/bin/env zsh
source ~/.bashrc
# Update brew
# https://brew.sh
echo "Updating brew..."
brew update
brew upgrade
brew cleanup
# Update Claude Code
claude update
# Update GitHub Copilot
gh extension upgrade gh-copilot
# Update global node modules
# Each package's own `engines` field decides what's installable -- no versions pinned here.
# npm >= 10 resolves the newest engine-compatible release; npm 9 and older ignore `engines`,
# so `--engine-strict` turns a mismatch into a clean skip instead of a broken install.
# Runtimes that cap out below npm 10 (node < 18.17) therefore stay put -- expect skip lines.
versions=($(nvm ls --no-colors --no-alias | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -u -V))
for version in "${versions[@]}"; do
echo "Updating global node modules for ${version}..."
nvm use ${version}
# Doubles as a health check: a broken npm prints an error instead of a package list.
listing=$(npm ls --global --depth 0 --parseable 2>&1)
packages=($(grep '/node_modules/' <<< "${listing}" | sed 's|.*/node_modules/||'))
if (( ${#packages[@]} == 0 )); then
echo " [!] cannot list global packages -- npm may be broken here"
echo " [!] repair: nvm uninstall ${version} && nvm install ${version}"
echo "${listing}" | tail -3
continue
fi
# One package at a time, so an incompatible one can't block the rest.
for package in "${packages[@]}"; do
if ! output=$(npm update --global --engine-strict --no-audit --no-fund "${package}" 2>&1); then
if grep -q EBADENGINE <<< "${output}"; then
echo " [!] skipped ${package}: newest release needs node $(grep -m1 'notsup Required' <<< "${output}" | sed 's/.*"node": *"//; s/".*//')"
else
echo " [!] FAILED ${package}:"
echo "${output}" | tail -3
fi
fi
done
npm list --global --depth 0
done
nvm use default
# Update python pip
versions=($(pyenv versions --bare))
for version in "${versions[@]}"; do
echo "Updating python..."
pyenv shell ${version}
pip install --upgrade pip
done
pyenv shell system
# Update ruby aliases
rbenv alias --auto
# Update oh-my-zsh
# https://ohmyz.sh
echo "Updating oh-my-zsh"
$ZSH/tools/upgrade.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment