Brewmancy Mac OS

Brewmancy Mac OS

May 29 2021

Brewmancy Mac OS

#showtooltip Keg Smash /cast Double Barrel /cast Keg Smash; This macro will automatically make use of the Double Barrel Honor Talent if you have it selected and cast it at the same time as your Keg Smash whenever the ability is off-cooldown. It will still work even if you do not have this Honor Talent selected and is useful if you would just like to benefit from its passive damage increase. Mac App Store command line interface. There’s one more tool that we need to cover before Brewfile: mas-cli is a simple command line interface for the Mac App Store (MAS). It can’t install apps that you haven’t downloaded or purchased before, but it will allow you to upgrade those that you have installed, and download apps tied to your.

Homebrew is a package manager for macOS. It's extremely easy to install, and, once installed, allows you to manage both your core packages and your (non-App Store) applications easily through the command line.

Suppose you want to install Google Chrome on your Mac. To do this manually -- i.e., without Homebrew -- you need to:

  • find the website on which it lives
  • download the installer
  • run the installer
  • drag icons around, and set permissions
  • junk the installer

To install Google Chrome through Homebrew, you need to type brew cask install google-chrome.

That's it.

Install Homebrew on your Mac

Use Homebrew to install command-line packages

You will now be able to install a variety of packages from the command line. For command-line packages, the installation format is brew install package. So, to install git, you’d run:

Popular packages include:

  • Zsh (zsh)
  • Composer (composer)
  • Node (node)
  • Wget (wget)
  • Bash (bash)
  • AWS-CLI (awscli)

You can find a full list of packages here, or generate a list by typing:

Use Homebrew to install full macOS applications

Once you have installed all the command-line packages you need, you can move onto installing full macOS applications. For full applications, the installation format is brew cask install package. So, to install Google Chrome, you’d run:

There are more applications in the repository than you’d think, among them:

  • Google Chrome (google-chrome)
  • Dropbox (dropbox)
  • Google Backup and Sync (google-backup-and-sync)
  • Adobe Creative Cloud (adobe-creative-cloud)
  • Microsoft Office (microsoft-office)
  • Sonos Controller (sonos)
  • Zoom (zoomus)
  • Skype (skype)
  • Plex Media Server (plex-media-server)
  • Github Desktop (github)
  • AppZapper (appzapper)
  • Atom (atom)
  • Etcher (balenaetcher)
  • Visual Studio (visual-studio-code)
  • iTerm 2 (iterm2)
  • Signal (signal)
  • Sequel Pro (sequel-pro)
  • Handbrake (handbrake)
  • Vagrant (vagrant)
  • VLC (vlc)
  • Transmission (transmission)
  • Burn (burn)

To obtain a list of all the available applications, run:

Use Homebrew to update packages and applications

Over time, you will need to update the software that is managed by Homebrew. There are a number of ways to do this.

To find out which packages need updating, run:

To update a particular package, run brew upgrade package. For example, to upgrade git run:

To ensure that Homebrew knows what is new and what is old, make sure that you sporadically update the index by running:

For full applications, use the same formatting as above but add the word cask between brew and upgrade. e.g.:

Use Homebrew to remove packages and applications

To remove any packages you no longer want, you can use either brew uninstall package or brew remove package. These two commands do exactly the same thing.

To remove git, for example, you’d run:

To remove full applications, just add the word cask between brew and uninstall. To remove Google Chrome, for example, you’d run:

If you have multiple versions of a package installed and you want to uninstall all of them, add --force into the string. So, for example:

If you are unsure which packages are installed on your machine, you can run:

Obviously, to find out which full applications are installed on your machine, you’d add the word cask, so:

Remove old versions of Homebrew packages

By default, Homebrew does not remove the old versions of upgraded packages; rather, it keeps them where they are, installs the new package in addition, and then links to the new package instead of the old one. Over time, this can begin to take up a good portion of your hard disk space. To force Homebrewto remove all old packages, run:

Find which version of Homebrew is installed

Versions

Homebrew: 2.0
Notice an error?

Have we got something wrong? Please let us know and we’ll fix it right away.

Tags
Command Line
April 22, 2019

Perhaps the most-dreaded aspect of setting-up a new machine is the time spent on reinstalling apps and reapplying all of the customizations from the previous one. As my MacBook Pro is about to turn six, I had been looking for a way to automate this process. At least for the applications part, I recently found a good solution (that’s apparently been around for a while).

This post is about using a Brewfile to migrate macOS packages and applications. If you’re already versed in the world of Homebrew and Homebrew Bundle, you might find it overly verbose. It’s written from a beginner’s perspective as up until recently I wasn’t too familiar with the concept myself.

Brewfile in a nutshell

A Brewfile contains instructions on which packages, command-line utilities, and applications to install on a macOS system. Here’s a short snippet:

If I were torun” this Brewfile, it would install the Python and SQLite packages, then 1Password, Pages, and Drafts from the Mac App Store, and finally Carbon Copy Cloner, Dropbox, and VLC from Homebrew’s repository (which usually pulls them from their respective websites). All apps are installed in the Applications folder by default, but the ability to differentiate between App Store and non App Store applications is significant in my case.

This is already faster than doing any of these steps manually. What’s more, a Brewfile can be generated automatically so you’d rarely need to write the lines above one-by-one.

Why Brewfile

Because the alternatives aren’t as good.

Cloning: Using the excellent Carbon Copy Cloner to clone my old HD to the new one would theoretically be the quickest way to get going, but after 6 years, I imagine there’s more than a little cruft in my system files, and recent changes to Apple’s hardware make this option even less attractive. There are also apps on my current machine that I actually don’t want to move over.

Time Machine and/or Migration Assistant: Migration Assistant hasn’t been known for its reliability lately, and Time Machine backups are not less problematic. Listing the advantages and drawbacks is beyond the scope of this post, but if you want to read more about the pros and cons of each migration strategy, Jason Snell does a good job on that.

Starting fresh: Nothing could go wrong, but a lot of time spent on configuration and installing apps.

A detour

To understand what a Brewfile does and how it can fit in a migration strategy, it’s good to be familiar with the moving parts that make it useful. This is not an exhaustive overview, but rather an introduction into each.

Homebrew

In the beginning, there was Homebrew, a package manager created by Max Howell in 2009. After installing homebrew, you can open the Terminal and install packages easily and quickly:

Behind the scenes, brew is using what it calls aformula” to install the ffmpeg package. This formula is a piece of code that’s responsible for holding all the information required to install ffmpeg: its name, version, URL to the source files that should be downloaded, and other packages that ffmpeg needs in order to operate.

Homebrew not only makes it easy to install packages, but also to maintain them:

Brewmancy

And to discover them:

homebrew is very nice indeed. It’s lauded for its ease-of-use, documentation and helpful command-line feedback.

Homebrew Cask

homebrew-cask is like homebrew, but for macOS apps, fonts, plugins, and other non-open source software. If brew install [formula-name] installs a package corresponding to that formula’s name, then brew cask install [cask-appname] installs an application with that cask’s name:

By default, it places installed apps in the Mac’s Applications directory. You can search for casks the same way you search for formulae:

But where is firefox coming from here? How does brew cask install firefox know what to install?

Brewmancy Mac Os 11

A few pieces of information here:

  1. firefox: 66.0.3 is the version we can expect homebrew-cask to install.
  2. From: holds the URL where the cask lives. If you inspect it you’ll see that somewhere in there is also the URL one would go to in the browser when installing Firefox theregular” way. There’s no magic here.
  3. Install options, like Languages. Running brew cask install firefox --language=it will install Firefox in Italian.

Indeed, homebrew-cask is very, very nice.

Mac App Store command line interface

There’s one more tool that we need to cover before Brewfile: mas-cli is a simple command line interface for the Mac App Store (MAS). It can’t install apps that you haven’t downloaded or purchased before, but it will allow you to upgrade those that you have installed, and download apps tied to your iCloud account:

mas-cli may not seem terribly useful at first glance, but it was the missing piece in my migration strategy since it provides a way to capture all Mac Store apps currently installed:

Yes, mas-cli is nifty.

So, brew install, brew cask install, and mas install make things a lot faster. The next step is to find a way to automate the generation and execution of these commands.

Homebrew Bundle

homebrew-bundle is an extension of homebrew and is installed as soon as the command brew bundle is first used. It’s the glue that brings everything together.

Run brew bundle dump and Homebrew Bundle will generate a file called Brewfile listing all of the installed brew packages, cask applications, and Mac App Store applications currently on the machine. If, on the other hand, you run brew bundle from a folder that contains a Brewfile, it will install everything listed in that file.

So, given a Brewfile with the following content:

Brewmancy Mac Os Download

Running brew bundle from the same directory where Brewfile is located will install the above packages and applications.

Notice that the Brewfile syntax differs from the commands you’d usually type in the Terminal. This table should help:

Terminal commandBrewfile
brew install [formulaName]brew '[forumlaName]'
brew cask install [caskName]cask '[caskName]'
mas install [identifier]mas '[bundleIdentifier]', id: [identifier]

I think you know where this is going by now: run brew bundle dump on the current machine, copy the Brewfile generated to the new one, run brew bundle, and Homebrew will take it from there. If you have lots of apps and packages the process will take some time, but nowhere near the time (or effort) it would have taken to do manually.

A quick-guide on setting up a new macOS using a Brewfile

Here’s an abbreviated guide to set-up a new macOS with Homebrew Bundle. Unless otherwise stated, all commands below are to be typed in the macOS Terminal prompt.

The steps involved are:

  1. Installing dependencies on the current (source) macOS machine
  2. Installing Homebrew taps
  3. Generating a Brewfile
  4. Migration

1. Installing dependencies on the source machine

Homebrew

Check if you already have Homebrew installed:

If Homebrew isn’t installed, the output should be something like brew: command not found. Homebrew itself depends on the command line tools (CLT) for Xcode, installed like this:

You can then install Homebrew by pasting the following in your Terminal prompt:

If you do have Homebrew, and help prints a long list of commands, it’s a good idea to run an update before proceeding:

Homebrew Cask

Comes with Homebrew, but it doesn’t hurt to make sure it’s there:

Homebrew Bundle

Will be installed as we run it (later).

Mac App Store CLI

The way to install this mas-cli varies depending on the OS version. You can find simple instructions in the project’s Github repository, but if you have a recent version this should suffice:

2. Installing Homebrew taps

Think of taps as additional sources brew will look at when searching and installing formulae and casks. Here’s what I recommend if you’re following this tutorial:

3. Creating the Brewfile

Now that all of the of the dependencies are installed, let’s generate a Brewfile:

Notice that Brewfile may be missing non-MAS applications and packages that you haven’t installed with brew or brew cask. If you installed Firefox from Mozilla’s website, homebrew-bundle doesn’t know about it. It’s easy enough to search for those and add them manually. And, it’s something you only have to do once since you’ll never ever again go to a website, find the install link, wait for the download to finish, and then drag the app icon to /Applications.

Brewmancy Mac Os X

A Brewfile looks something like this:

If you’d like to omit some packages or otherwise change the Brewfile that your target macOS will use, you can simply copy the file somewhere else and make your changes there.

I keep my Brewfile in a Github repository, but you can place it in Dropbox, Google Drive, or wherever.

Brewmancy Mac Os Catalina

One more change I do is placing all mas directives before the cask ones, so the App Store version of an app is preferred in case that app is mistakenly listed in both sections.

4. Migration

The only dependency needed on the new machine is Homebrew (see step 1). That’s because the Brewfile pulled from the old setup already stages all others for installation.

Once Homebrew is installed and a Brewfile is present, it’s as simple as running:

brew bundle will look for a Brewfile in the current directory, but you can also specify the path manually:

If you enjoyed this post, please consider donating to Homebrew.

Brewmancy Mac OS

Leave a Reply

Cancel reply