rcmdnk's blog

Apple MacBook Air MD760LL/B 13.3-Inch Laptop (NEWEST VERSION)

I’m managing Mac’s packages with Homebrew.

To keep own update history or share the settings to other Mac, it is very useful to make a list of packages.

For this purpose, I have developed Bew-file, which is an extension of Homebrew.

Sponsored Links

What is Brew-file?

Brew-file was made inspired by Brewdler, which uses Brewfile, a list of packages and applications, to install at once. Brewdler was implemented into Homebrew, but it became obsolete.

Bew-file uses Brewfile too. It can also make and update from installed packages. In addition, it has a function to manage Brewfile in a GitHub repository, so that you can keep a history of your installation, and easily share the same setting to another Mac.


You can install Brew-file by Homebrew like:

$ brew install rcmdnk/file/brew-file

If you haven’t installed Homebrew, you can install Homebrew and Brew-file together by:

$ curl -fsSL https://raw.github.com/rcmdnk/homebrew-file/install/install.sh |sh

Then, you became able to use brew file command. Try brew file help for the basic usage.

If you have installed homebrew-cask for an application management, you can manage these applications by brew file, too. You can even install homebrew-cask by brew file, of course.


brew file commands

Here are basic commands of brew file:

Command Function
install Install packages in Brewfile (do ‘brew update’, too).
init (or -i) Initialize/Update Brewfile with installed packages.
et_repo (or -s) Set BBrewfile repository.
clean (or -c) Clean up packages not listed in Brewfile. This runs as dry-run by default. Use -C to enforce cleanup.
pull Update Brwefile from the repository (if it is set).
push Push Brewfile to the repository (if it is set).
edit (or -e) Edit Brewfile (by vim or $EDITOR if it is set).
casklist Check applications for Cask.
help (or -h) Show help

For more information, see brew file help or README.


Brewfile is a core part of Brew-file. This file is normally located in /usr/local/Library/Brewfile.

This can be changed by -f option, or set it in your setting file (such .bashrc) like:

$ export HOMEBREW_BREWFILE=~/.brewfile

A basic Brewfile is like this:

# tap repositories and their packages

## caskroom/cask
tap caskroom/cask
install brew-cask
cask install adobe-reader

## rcmdnk/file
tap rcmdnk/file
install brew-file

# Other Homebrew packages
install git
install vim --HEAD --with-lua

# App Store applications
appstore GarageBand
appstore iMovie

The format is command <package> [<options>] for each line. The line starting with # is comment line.

Available commands in Brewfile are as follows:

Command Function
install <package> [<options>] Execute brew install <package> [<options>]. You can give options after package name as command line.
brew <package> [<options>] Same as install, for the compatibility with Brewdler.
brew install <package> [<options>] Same as install.
tap <repository> Execute brew tap <repository>.
tapall <repository> Execute brew tap <repository>. In addition, execute brew install for all formulae in the tap.
cask <app> Execute brew cask install <app>, by using Homebrew-cask. If the first argument is install, it is ignored. (cask package and cask install package work in the same way.)
cask install <app> Same as cask <app>
pip <package> execute brew pip <package>, by using brew-pip. (Note: brew-pip seems obsolete.)
appstore <app> Just show Please install <app> from App Store!
before <cmd> Execute <cmd> before any other commands. (e.g.: You can write such before sudo softwareupdate -i -a for system update.)
after <cmd> Execute <cmd> after any other commands.
Other any words: <cmd> Just Execute <cmd>, after any other commands other than after commands. after and before commands are kept at initialization or update, while these other commands are not kept.

Set GitHub Repository

Brew-file can use Brewfile in the repository on GitHub.

To set the repository, do

$ brew file set_repo
Set repository, "non" for local Brewfile,
<user>/<repo> for github repository,
or full path for the repository:

You will be asked a path of the repository, then give like rcmdnk/Brewfile.

If the repository doesn’t exist, it proceeds to the procedure making the repository.

Then, you can pull/push the repository by brew file pull/brew file push, respectively.

Install packages

If you already have Brewfile, you can install packages and applications in Brewfile, by:

$ brew file install

It is very powerful when you setup Mac for the first time.

warning For applications of App Store, brew file install just shows messages prompting you to install these applications from App Store. (Currently I don’t have any way to install App Store applications from command line…)

Initialize Brewfile

For the first time, you can make Brewfile from installed packages. Just do:

$ brew file init

Check applications for Cask

You may have installed many applications directly other than Homebrew-Cask or App Store.

These applications can be installed by Homebreww-cask.

brew file casklist will make Caskfile in the current directory.

brew file casklist searches applications in /Applications, /Applications/Utilities, ~/Applications, ~/Applications/Utilities, and make a list of:

  • Apps installed by Cask.
  • Apps installed directly instead of by Cask.
  • Apps installed but no casks are available.

For applications, Apps installed directly instead of by Cask, it is good to remove them, and add the result in Caskfile to Brewfile, then install these applications by brew file install. So that you can easily manage these applications by Brew-file.

Update Brewfile

brew file update does pull/brew update/install/brew upgrade/initialize/push/clean.

You can easily synchronize two Macs by doing brew file update in each Mac. It is useful if you set brew file update in cronjob or launchd to execute once a day.

Edit Brewfile

If you want to edit Brewfile directly, you can use brew file edit to open and edit Brewfile.

A default editor is Vim. $EDITOR variable is used as editor if it is set.


When you execute such brew install, Brewfile is not updated. You need to execute brew file init or brew file update to update Brewfile.

If you want to automate it, etc/brew-wrap is available.

This file has a wrapper function of brew in which brew file initialize is automatically executed after such brew install command.

To enable this wrapper function, source this file in your setting file such .bashrc:

if [ -f $(brew --prefix)/etc/brew-wrap ];then
  source $(brew --prefix)/etc/brew-wrap

This brew wrapper function executes original brew if brew file command is not available so that you can safely uninstall/re-install brew-file.

Sponsored Links
Sponsored Links

« New blog with Octopress + Octogray, in GitHub Pages Speed up Octopress generate for a check build »