Computers are supposed to make our lives easier. But when a new system needs configured or wiping out and reloading an old system, it can feel like an over whelming job. Many individuals use programs from different websites. Going to each website, downloading the correct version for the system, extracting the program, and loading it to the proper location can take a long time.
Homebrew will install common free Unix type programs, but not browsers and other graphical programs. That’s the advantage of Cask. Cask is a utility that sits on top of Homebrew to install many commonly used programs for the Mac. Since it’s a command line utility, scripting the installation is a snap!
Homebrew has to be on the system. If you haven’t installed Homebrew yet, the tutorial Homebrew Demystified: OS X’s Ultimate Package Manager will show you how.
With Homebrew installed, you can install Cask by typing these command lines in a Terminal window:
brew tap phinze/cask brew install brew-cask
The top line sets up the Cask tap in Homebrew. A tap is a download location for information to install programs using Homebrew. This one is referring to a different GitHub account and repository in that account to get the information.
The second line installs Cask into Homebrew.
Note: Pictures taken with a white background in the Terminal program are from a fresh Mac OS X installation on a virtual machine that didn't have Homebrew or Cask installed already.
With Cask installed, you can see all the commands Cask understands by typing in the Terminal window:
The commands to remember are:
This command allows you to search for a program that Cask knows how to install. Since the name that Cask uses isn’t always the program’s true name, it will be necessary to search for the program.
For example, if you type in a Terminal window:
brew cask search chrome
That will produce the output:
The google-chrome is the name to use when installing Chrome browser from Google.
This will install the program given after the command. To install Chrome, you type
brew cask install google-chrome
Google Chrome is now installed on the system. It is ran like any other program.
This will list every program installed with Cask. With Alfred and Chrome installed, entering into Terminal this command will produce:
brew cask list alfred google-chome
Cask only writes it’s name for the programs, not the most commonly used name.
If you use Alfred to launch programs, you will want to use this command to modify Alfred’s search path to include programs you install with Cask. To link the Cask programs in Alfred, enter this in the Terminal:
brew cask alfred link
This command tells Cask to remove the downloaded zip or dmg files from the computer. After installing many programs, this will free up a lot of disk space.
This picture shows alfred link, list and cleanup commands.
This command uninstalls the program given.
Like the brew doctor command, brew cask doctor will analyze the system and see if everything is okay for using Cask. If there is a problem, Cask will tell you how to fix it.
This command will open your default web browser on the homepage for the program. If you run the command brew cask home google-chrome, the default web browser will open to the homepage for Google Chrome.
Making an Install Script
Using the brew search and brew cask search commands, find out the names for each program needed in the install script. For example, you want the latest php xdebug program installed. In the Terminal, type:
brew search php56-xdebug
Homebrew will reply with:
The one you want is the homebrew/php/php56-xdebug. Searching for php56 gives a large list since PHP has many add-ons.
You also want Text Expander loaded, but your not sure what Cask would call it. To find it, look for a small part of the name. In a Terminal, type:
brew cask search text
Cask will come back with:
==> Partial matches atext sublime-text textexpander textroom texturepacker contexts textadept textmate texts textwrangler
That gave two programs that you wanted: sublime-text and textexpander.
Using the text editor, create the script using the search information:
#!/bin/sh # # Brew packages that I use alot. # brew install wget brew install homebrew/dupes/tidy brew install homebrew/php/php56 brew install homebrew/php/php56-xdebug brew install homebrew/php/phpsh brew install fish brew install ffmpeg brew install node brew install imagemagick # # Some cask packages that I like. # brew cask install aquamacs brew cask install dropbox brew cask install textexpander brew cask install sublime-text brew cask install macvim brew cask install alfred brew cask install controlplane brew cask install gimp brew cask install google-chrome brew cask install inkscape brew cask install xquartz brew cask install virtualbox
Save this to a file called installConfig.sh. In order to run this script as a program, change the file mode to executable by typing this command in a terminal where the script is:
chmod a+x installConfig.sh
With a new system, put this script in the home directory and run it by typing ./installConfig.sh.
You now have 21 programs installed with one simple command. Since Homebrew and Cask understand interdependencies of programs, more than 21 programs are now on the system. All of those programs were downloaded, compiled if needed, and installed automatically.
This small installer takes about a hour to run, but you can start it and let it go until it finishes. If some of the programs are already installed, Homebrew and Cask will skip it and not crash out of the installation. Your time is not spent watching over the installation.
Cask makes the installing of programs easy on Mac OS X. With the basics given, you can now create your own installation script using Homebrew and Cask. Create your own script to match your needs and keep it handy. You never know when you might need to use it.
Subscribe below and we’ll send you a weekly email summary of all new Computer Skills tutorials. Never miss out on learning about the next big thing.Update me weekly
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post