It is common to buy a new Mac, install a bunch of applications, add some media and leave it running without any cleaning/ maintenance over Mac’s lifespan. All this activity can cause your Mac to slow down, causing bugs, issues and performance lag, degrading your Mac experience. Where some may opt to buy a new Mac, there is often a much cheaper (and more straightforward way) of keeping your MacBook “purring”, stretching out its lifespan significantly and keeping you, it’s owner, smiling.
With this mini-series I hope to give some easy to follow advice which anyone can follow to help make their Mac as efficient as possible, saving your time while improving your Mac’s performance, helping keep that smile you had when you bought your first Mac. I will talk both about enhancing a Mac you already have as well as time effective methods for setting up a brand new Mac. If you have any questions/ comments, please feel free to get in touch in the comments below.
To kick off the series; have you ever wondered if there was a better way of managing all your applications, keeping them up-to-date and avoiding those dreaded update messages that always seem to appear? There is, with Homebrew 🍻. New to Homebrew? No problem, let’s talk through how to get the ultimate Mac setup whatever your situation.
What is Homebrew?
Homebrew is a free package and application manager for the macOS operating system. Through using the command line, you can install and update applications all in one central nearly every application or update everything in just a couple of words, for example:
brew install google-chrome
That one line will download and install the latest copy of Chrome. Yes, it’s that easy. To update all your applications, all that is required is:
brew cask upgrade # or brew cu -a
In essence, if used as intended, Homebrew can save countless hours of time by eliminating all manual application management tasks.
Homebrew is delightfully simple to get up and running. To place a fresh installation on your machine, open terminal and paste the following line (and return):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
That’s it! You can now install and update applications with a couple of typed words. I like to take this one step further by adding two additional programmes:
brew tap buo/cask-upgrade brew install mas
cask-upgrade provides a fantastic interface to manage all GUI applications, allowing further flexibility in what you install run.
mas extends the command-line interface to all Mac App Store downloads. Now all your apps are covered by Homebrew.
Moving All Applications to Homebrew
The next step is to port or install all your applications to Homebrew. At this stage, you have two options discussed in turn. Before proceeding, it is worth making a special note of any licences that you have for paid software. Depending on how you remove an application from your Mac, you may require re-inputting this information when you reinstall the app.
Option One: Automated brew-app-replace script
To simplify this process entirely, I created an adapted python script, which goes through all your applications, identifies whether the apps were installed by the Mac App Store, by Homebrew or manually. If an app is found to have been installed manually, the script will search the Homebrew directory for a matching application and reinstall this application so Homebrew now manages it.
To use this script, go to myHomebrew-app-replace GitHub page, then clone the directory to a sensible location. Go to this directory in your command line in my case this is
cd Documents/Development/TerminalApps/homebrew-app-replace. Inside this directory there are two main files, these are
brew-app-replace.py. If you have never used Python on a Mac before, do not worry. Your Mac will already come with Python 2.7 installed natively along with the
pip python package manager. Together without any additional installation, you can run python code natively.
There is a particular python package which does not come installed natively; requiring an additional line of code:
pip install -r requirements.txt
This line installs any additional packages with
pip making sure the script will run as expected. Finally, you can execute the script with:
Run as above; the script will identify all the applications that you have installed and ask you individually whether you want to replace them with a corresponding Homebrew installation. Just type
n on each app it asks you to replace. The script does this on purpose to stop you from overwriting any apps you may not want to be managed by Homebrew. Alternatively, if you have complete faith in the script, you can run the app with
-y which will automatically replace everything that it can. Your choice. A word of caution; this script is not fully tested, although, in theory, it should not raise any issues, in practice different results may occur.
Option Two: Manual App Replace
If you are not comfortable using the script, the other alternative is to create a list of all the applications you have installed, identify whether they are available via Homebrew (most applications generally are), delete the app ( a tool like AppCleaner,
brew cask install appcleaner, is very useful for doing this quickly) and then reinstall via Homebrew .
The quickest way of manually brew-replacing all your applications is by using
brew leaves. This creates a single file with a list of all installed Homebrew applications and allows you to add additional applications to the list for single line installation. A good process is:
- Open up terminal
- Create a
Brewfile– this is a file with a list of all your applications installed by Homebrew.
brew bundle dump, this will create a
Brewfilein your current directory (most likely root) :
- Open up the
Brewfilein a text editor . This should look something like:
tap "buo/cask-upgrade" tap "homebrew/bundle" tap "homebrew/cask" brew "nmap" brew "node" cask "intel-power-gadget" cask "intellij-idea" cask "iterm2" cask "google-chrome" mas "iMovie", id: 408981434 mas "Keynote", id: 409183694 mas "Numbers", id: 409203825 mas "Xcode", id: 497799835
- Make a mental note of the applications with
masbefore them. The Mac App Store already manages these applications so you don’t need to worry about them
- Next, open up AppCleaner; this will provide a list of all the applications installed and a very easy and effective means of deleting each app (entirely).
- For each non-MAS app, you will want to search the Homebrew library with
brew search application-nameoften spaces are replaced with dashes or removed entirely.
- If the application exits, it’s safe to replace. Add a new line the
BrewFilealong the lines of
cask "google-chrome"(note GUI applications, typically are casks). Make sure the name you use matches the corresponding result found from you cask search.
- You can then delete this application from your Mac; either using App Cleaner or dragging the app to the trash.
- Repeat steps 6-8 until you have successfully replaced all your applications with their Homebrew managed equivalent.
If you don’t like the idea of batch installing, you can instead install each application individually through
brew cask install application-name; a little slower but you are sure to install the correct app.
Now that you have successfully moved your applications across to Homebrew, it is time to reap the rewards.
Some quick tips…
Update Everything In One Step
brew-cask-upgrade, a lovely visual representation of the state of all installed apps.
Update Everything In One Step
brew-cask-upgrade, a lovely visual representation of the state of al the installed apps is provided.
brew cu -a # pass -y as well if you wish to update everything blindly
This will find all the outdated apps and update them in a single sweep. Gone are the days of update messages every-time you open an application.
Install New Apps in a Breeze
Have a new application you wish to install, no problem. Just run a
brew search app-name to see if the application is in the Homebrew library, then
brew cask install app-name if it exists. No more dragging and dropping files and working through installations steps.
Remove Your Old Applications
As quickly as your app was added, you can remove it in a pinch. Simply type:
brew cask uninstall app-name brew cask zap # Removes all files associated with an application
Done, that app is no more along with the files apps often leave behind.
Update All your Mac App Store apps in One Go
Why waste time going to the Mac app store, instead just type;
And all Mac App Store applications will be updated to their most recent version.
Some other tips
- Free up some disk space. Run
brew cu --cleanup. This will remove any old
.dmgfiles that may linger after an app is installed.
- Port, all applications to another Mac, keep two MacBooks Synchronised – to come in a future post
- Get a list of all your applications:
brew list brew cask list mas list brew bundle dump
And that’s it; your Mac applications are now fully managed in a highly optimised and convenient manner. It is now straightforward to keep everything up to date and add and remove apps. Through going through the process of replacement, your application files should now be tidy helping improve the performance of your Mac.
Porting your applications to Homebrew will also make it very easy when setting up a brand new MacBook, leading into the second part of the series; A New Mac.