Created
May 25, 2023 16:28
-
-
Save mikesprague/a9600842f43691bf4d608cb419733df7 to your computer and use it in GitHub Desktop.
Bash script to run some common updates/commands I use
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
#!/bin/bash | |
# PREREQUISITES: | |
# - Homebrew | |
# - Zsh | |
# - oh-my-zsh | |
# - Node.js with the following global packages installed: | |
# - npm-check-updates | |
# - n | |
# - Docker | |
# homebrew housekeeping | |
brew cleanup && brew doctor | |
# update/upgrade homebrew packages | |
brew update && brew upgrade | |
# update oh-my-zsh | |
"$ZSH/tools/upgrade.sh" | |
# make sure LTS version of Node.js is installed (and npm is up to date) | |
n lts && npm i --location=global npm corepack | |
# make sure latest version of Node.js is installed (and npm is up to date) | |
n latest && npm i --location=global npm corepack | |
# run npm-check-updates on global npm packages | |
command=$(ncu -g | tail -n 2) | |
# if there are any updates, upgrade those global packages | |
update_string='npm -g install' | |
if [[ "$command" == *"$update_string"* ]]; then | |
# echo "$command" | |
eval "$command" | |
fi | |
# update all docker images | |
for image in $(docker images --format "{{.Repository}}:{{.Tag}}"); do docker pull "$image"; done | |
# remove any stale docker images | |
docker rmi -f "$(docker images -f dangling=true -q)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment