Update Homebrew on macOS With One Script

I use multiple Homebrew packages and I appreciate Homebrew’s built in package management, so each time I update Homebrew packages on my mac, I get tired of typing multiple commands, especially since I like to be thorough. I use brew update to update the formula and Homebrew itself, brew upgrade to update everything, brew cleanup to delete any unfinished downloads, and finally brew doctor to check for issues.

My initial thought was that I could just create a simple alias to run all four commands at once:

alias brewup='brew update; brew upgrade; brew cleanup; brew doctor'

I decided to improve on the idea and create a bash script that would run all the commands and echo messages back to me as it was running. I did it like this:

I used the printf command to tell me which part of the script is currently being executed, so if the script appears to be hanging I know how far it completed. I formatted the text to use a color that doesn’t appear elsewhere in my terminal’s color scheme so that I know that the outputted text is from my script rather than as a result of a Homebrew process.

Finally, I named the script brewup, stuck it in my ~/bin directory and made it executable from any directory:

chmod +x brewup

Now that the script is executable I can run the script no matter how far down I’m working in a nested directory. When I want to update my Homebrew packages, I can type a single word and let Homebrew update in one terminal window while I work on something else:


If you like what I did and want to save yourself some typing, you can get a copy of the script from my GitHub.

Published by josephmidura

I am a software developer in Austin.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: