This week the irrepressible Knightwise of knightwise.com sent in an awesome tip via audio, and it’s too good not to share in text as well. I’ll do my best to do it justice. I’ll start with the problem to be solved (of course) and then give a little bit of background and then his tip. Finally, I’ll give you bonus tip from me.
The problem to be solved is finding the easiest way to reinstall apps you’ve previously downloaded from the Mac App Store, especially when doing a nuke and pave, or moving to a new Mac but you don’t want to bring along the cruft you’ve collected over the years.
To follow along with Knightwise’s tip, you’ll need to know about Homebrew. Homebrew is a free and open-source, command-line package management system that simplifies the installation of applications on macOS.
The installation of Homebrew on your Mac is done of course via the command line. Navigate to brew.sh in your web browser and you’ll see one long command on the page. It looks scary but simply open up the Terminal, paste in the command, and it will install Homebrew and you’ll be ready to play with Knightwise’s tip.
Once you’ve installed Homebrew, installing apps via Homebrew is accomplished by simply typing
brew install followed by the name of the app.
Now back to our problem to be solved. The packaged app you want to install is called mas, which is short for Mac App Store. To install mas, you simply type
brew install mas. You’ll see a download of a compressed gzip file and a couple of seconds later it’s installed.
Now that you have mas installed, you can tell it to list all of the apps you have installed on your Mac that came from the Mac App Store. Simply type
mas list. You’ll get a list with a long number in the first column, followed by the name of the app and the currently installed version. It’s a beautiful thing.
The long number is the code the Mac App Store uses to identify apps. If you’ve ever clicked on a link to take you directly to an app in the Mac App Store, in that link is this same long number. Let’s demonstrate this by example. I can see Yoink in my list generated by mas. Next to Yoink it says 457622435. If you go into the Mac App Store and search for Yoink, there’s a little downward chevron next to Buy (or Open if you already have it installed). If you click on that chevron, you can choose Copy Link. I’ll paste the link in the shownotes as plain text: https://itunes.apple.com/us/app/yoink-improved-drag-and-drop/id457622435?mt=12. You can see near the end of the link it says id followed by the same digits we saw in the mas listing. It’s good to understand the reason for that number because we’re actually going to be using it with mas.
Using the simple command
mas install followed by the number, we can install any app we’ve previously acquired through the Mac App Store.
To demonstrate mas, I decided to uninstall and reinstall an app for you. I started by deleting Yoink using AppDelete (mas doesn’t delete apps). Then I re-ran
mas list to verify Yoink was no longer in the list. Now here’s the fun part. I typed
mas install 457622435 and it installed Yoink for me without ever opening the Mac App Store!
It’s truly amazing to me that this app is able to send the right code to the Mac App Store and tell it what to do. The documentation for mas is very clear, you must have already bought (or downloaded for free) the app in the Mac App Store in order to install with mas.
You also have to be logged into the Mac App Store to do this as well. If you happen to be logged out, you can even sign into the Mac App Store from mas. simply type
mas signin youremailaddress and you’ll be prompted for your Apple ID password and you’re in. For some reason this didn’t work for me, mas insisted that I was already logged in when the Mac App Store thought I was not. Made me sad that I had to do it the old-fashioned way.
Here’s another great command. How annoying is it to try to find an app you’ve previously acquired from the Mac App Store? What order are they listed in anyway??? It’s not alphabetical, I know that for sure, and it’s not exactly time-based either. And of course Apple doesn’t let you search for apps within the Purchased tab. I know you can search from the main pages of the Mac App Store and if you’ve bought it before it hopefully says download instead of buy but I’ve had that trick me up before.
With mas, you can enter into your Terminal window
mas search Yoink and it will return the code for Yoink ready for you to install again. That’s got to be about 236 times faster than finding it in the Mac App Store.
Want to know what apps need to be updated on your Mac? Type
mas outdated. I didn’t even realize I had pending updates but I found out Slack, Amadeus Pro, Telegram and Paprika all want updates right now.
Let’s take it up a notch and instead of launching the Mac App Store to actually do the updates, let’s update the apps right from mas. Type
mas upgrade and it upgrades all of your out-of-date apps. I don’t know about you, but launching the Mac App Store and waiting ages for it to animate to do the installations has become quite the bore. Doing it with mas was much faster and somehow it felt like cheating!
If you’re of the script-writing persuasion, you can see how fun it would be to write a script to download the list of apps and their codes to a file and then run that list as an input on a new Mac.
I mentioned the Previous Purchases tab earlier, If an application is no longer in the Mac App Store and so no longer in your Previous Purchases, mas won’t be able to install it.
When you forget all of the commands I taught you, or to look for more commands, type
mas help and you’ll get a full listing. If you’d like to read more or even download the source code for mas, go to github.com/…
I promised at the beginning that I had a little tip for you to add to all of this. I’m able to remember the command
brew install but I don’t actually know any of the other brew commands. I could learn them but I’m not a frequent brewer so I haven’t bothered to memorize them. One thing you might want to learn to do is to keep the apps updated that you install from brew.
Enter Cake Brew. I learned about Cake Brew from John F Braun on the Mac Geek Gab. Cake Brew is a GUI interface for Homebrew. I know, it’s counterintuitive to use a GUI when we’re going to all this effort to use the command line, right? But I’m going to use Knightwise’s tag line, “Making technology work for you.” If a GUI works for you, use it!
Cake Brew shows you what apps you have installed (it calls them formulas for some reason). With the click of a button you can uninstall an app, but there’s also an Outdated section. With the click of a button in that tab you can update all of your apps.
I think Cake Brew is a slick little app and it helps me keep track of my Homebrew apps without having to remember the commands.
Many thanks to Knightwise for telling us about mas and I hope you have as much fun with it as I am.