Before starting, ensure Homebrew is installed correctly by typing brew
. If it doesn't work, follow their instructions here (ensure you do the final instructions after running the command!)
-
Open TextEdit, and create a new document
-
Go to
Format
→Make Plain Text
- Add in the syntax after
brew install
in the Formulae, each on a new line (e.g.brew install --cask utm
becomes--cask utm
andbrew install macfuse
becomesmacfuse
) — An example file can be found here
-
Save this as
packages.txt
somewhere (I put it in my Downloads folder) -
Open Terminal
cd
to yourDownloads
folder:
cd Downloads/
- Then install all the packages recursively in
packages.txt
by running the command:
brew install $(grep -v '^--cask' packages.txt) && brew install --cask $(grep '^--cask' packages.txt | sed 's/^--cask //')
brew install
can install multiple packages at once by just queueing them up, one after another (e.g.brew install gh bitwarden-cli
), however has to installcask
andnon-cask
packages separately. The above command separates this into two commands.
- Let Homebrew do its magic!
Before starting, this requires the mas
package to be installed via Homebrew (brew install mas
) and you have to be logged in to the Mac App Store. You can do this by opening the App Store (the mas signin
command no longer works).
Reinstalling a Mac? Find your Mac App Store Apps by using the System Information app (you can search for it as an app or go to
>About This Mac
>More Info...
>System Report...
>System Information
), then go toSoftware
>Applications
and use theObtained from
header to sort byApp Store
.
My current setup is using mas install
to get my previously purchased/installed apps. I do this recursively through my mas-apps.txt
file using the command:
grep -v '^\s*#' apps.txt | awk '{print $1}' | xargs -n 1 mas install
Breakdown:
-
grep -v '^\s*#' apps.txt
- Removes any lines starting with # (so I can comment them out), or empty lines -
awk '{print $1}'
- Extracts only the first field (the app ID), ignoring everything after it -
xargs -n 1 mas install
- Passes the cleaned app IDs one by one tomas install
I have set up this file with two columns, the app-id
and it's name. The name is only there to help me identify whether I still want it. This is why the above command is a bit more complex.
You could adjust this to 'purchase' (which doesn't actually buy things, only gets free things - see the mas documentation):
grep -v '^\s*#' apps.txt | awk '{print $1}' | xargs -n 1 mas purchase
Note: You also need to be logged in to use this command