Keeping macOS clean: this is my osx/brew/[…] update CLI command

I’m using OSX most of the time (you know, developer AND sales, plus being CEO) and this is the script I use to update it all the time, can be useful for some…

#!/bin/bash
brew update
brew upgrade
brew cleanup -s
brew cask cleanup
#now diagnotic
brew doctor
brew missing
apm upgrade -c false
/opt/bin/updateCCTF.sh && terminal-notifier -message “git pull done :-)” -title “CCTF up to date”
echo “you can hit mas upgrade to upgrade theses apps from the app store:”
mas outdated
echo “install with: mas upgrade”
npm update -g
echo “did you think to launch gem update “
echo “and pip ? pip freeze — local | grep -v ‘^\-e’ | cut -d = -f 1 | xargs pip install -U “

Ok, now I’ll explain it, line after each line:

brew update

Brew is the mainstream package manager for macOS, it provides all GNU softwares (many macOS tools like sed are outdated, GPL 2VS3 apple…), and many other CLI tools (I use it for mongoDB, redis, php, git, elixir…). If you don’t use it, it’s weird, you need to have it. The update command will update the local base of available packages and versions, to be able to know what is updatable.

brew upgrade

It actually installs new version of outdated packages

brew cleanup -s

By default, brew keeps all versions of the software, and you can link the one you want. This allow you to keep only linked versions (by default, the last) and save some disk space.

brew cask cleanup

brew cask is a brew extension for GUI and binary packages, some software are installed with it for simplicity of updates. This cleanup is cache cleanup for unfinished download. So, disk space savior.

brew doctor
brew missing

Will show you any problem with your brew installation, it will help a lot to maintain a healthy system all the time.

apm upgrade -c false

I use Atom as main text editor and IDE. The apm command is a CLI package manager for atom plugins. Very helpful. This command upgrades all packages it can, no questions asked.

/opt/bin/updateCCTF.sh && terminal-notifier -message “git pull done :-)” -title “CCTF up to date”

This is Clever Cloud specific, we use a git based wiki as internal documentation, and we all keep an up-to-date version of it. Because it contains all we need (except credentials of course) to relaunch the whole infrastructure. Better to get manual with me all times 😜

terminal-notifier is able to easily print notification on macOS notification system (you can use homebrew to install it)

echo “you can hit mas upgrade to upgrade theses apps from the app store:”
mas outdated
echo “install with: mas upgrade”

The mac app store UI is so SLOW, buggy and unfriendly that I use mas to manage my software installed using the appstore. It’s a friendly CLI you can install via homebrew. I do not automatically install updates to prevent software restart in middle of something. But this way I will launch it if there is some outdated software.

npm update -g

This will update all the npm global installed binaries, like grunt, lessc or Clever Cloud CLI (I know we need a proper homebrew tap and package, it’s on the task list of someone on the team).

echo “did you think to launch gem update “

Reminder to launch a global installed gem update (rake, bundler…)…

echo “and pip ? pip freeze — local | grep -v ‘^\-e’ | cut -d = -f 1 | xargs pip install -U “

Yeah, pip needs a proper pip upgrade command. I agree. Basically it’s used to upgrade VirtualEnv…


So, That’s all for now, and it keeps my laptop as healthy as possible. I’m not so happy with this script, but it does the job. Do you have any suggestions or ideas to make it better? Did I miss something?

BTW, I decide also to split my .bashrc into several file, read how here

A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.