Search Results for “#tech”

Page 1 of 1

Automate The Installation of All Your Mac Apps Using Homebrew

On macOS it's pretty easy to automate the installation of all your apps, including Mac App Store apps, for those times when you get a new Mac or wipe your current one. As a software developer I find this capability indispensable, as would any professional or power user.

All you need to do is install Homebrew and then use it to install mas (which is an acronym for Mac App Store). Once they are installed, you can install all your software using a convenient Bash script. Homebrew will be used to install non-store apps, and mas will handle installing the Mac App Store apps.

Note: only Mac App Store apps you have already installed previously can be installed with mas. You cannot install new apps you have never installed from the store.

Why Do This?

The most obvious reason to script out your software installations is that it greatly reduces the time to set up a new Mac, as well as ensure that you don't forget to install one or more apps. It also provides a way to update all the apps at once via the brew upgrade command. And it also provides a way to update apps that don't have their own update feature.

Apps installed with mas will be updated normally by the Mac App Store.

How Does This Work?

In order to use this process you need to know the names of the Homebrew formulae/casks for each application, and you also need to know the IDs of the Mac App Store apps for mas. Fortunately this is super easy.

First, Homebrew has a tool for finding software available in their service at https://formulae.brew.sh/. Simply use this to find your apps and make sure you're installing the right ones. Those listed as “casks” are GUI Mac apps (normal apps you don't run from the Terminal). Ones listed as “formulae” are typically command line tools run from the Terminal or services without an interface.

Second, for Mac App Store apps you simply use mas to list what's currently on your computer from the Mac App Store.

mas list

This will give you a list of currently installed apps from the Mac App Store, with their IDs:

1569813296  1Password for Safari      (2.10.0)
975937182   Fantastical               (3.7.12)
409183694   Keynote                   (13.0)
etc.

You can also search for Mac App Store apps by name using the mas search command:

mas search Xcode

This will show a similar result for matches. You can even install all search results with a single “lucky” command. See the mas help for these and other options.

Script Example

Here's an example of a Bash script to get you started. I keep a similar script updated as I use new apps or stop using others. Then I'm ready to go when I have to set up a new or wiped Mac.

# Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# App Store Automation

brew install mas

# Install App Store Apps

mas install 409183694   # Keynote
mas install 409201541   # Pages
mas install 409203825   # Numbers

# Install Non-Store Apps

brew install --cask firefox
brew install --cask knockknock
# etc.

You can name the Bash script something like install-software.sh and execute it in a Terminal like this:

zsh install-software.sh

The first time you use the script will absolutely justify the time spent writing it. The second time you run it you will thank your past self for being so smart 😉

#apple #macos #mac #tech #code #recommendation #YOUREWELCOME

May 2, 2023


Copyright © 2024 Michael Argentini. All rights reserved.