Brew-file manages packages installed by Homebrew. It also supports brew-cask and other Homebrew subcommand installers.
It uses input file. By default, the file is ~/.config/brewfile/Brewfile.
You can reuse
Brewfile for Brewdler, too.
If you want to specify input file, use
If you want to change default
Brewfile, set environmental variable:
in your setup file (e.g. .bashrc), like:
You can also modify the default installation locations of Cask packages. To make this settings, it is the same as issuing How to Use Homebrew-cask#Options. You might want to add the following line to your .bashrc or .zshenv:
If there is no
Brewfile, Brew-file will ask you if you want to initialize
with installed packages or not.
You can also make it with
install subcommand, Brew-file tries to install packages listed in
Brewfile convention is similar as Brewdler.
Normally, you don’t need to modify anything on Brewdler’s
Brewfile for Brew-file
# Tap repositories and their packages tap rcmdnk/file brew brew-file # This will install all packages in rcmdnkpac tapall rcmdnk/rcmdnkpac # Homebrew packages brew mercurial brew macvim --with-lua # Cask packages tap homebrew/cask cask bettertouchtool # Additional files file ~/.Brewfile
First column is command.
Second to the last columns are package name and options.
They are used as arguments for such
therefore any options of Homebrew can be used.
|Command||For what? (X is package+options)|
|appstore||Apps installed from AppStore. The line is like: appstore <identifier> <App Name>. Identifier can be obtained by argon/mas. (It will be installed automatically.) For older OS X, it might be not available. For such a case, only App names are listed by
|main||Main file. If it exists, new packages will be written to the main file instead of the top file.|
|file||Additional files. A path is a absolute path, or a relative path, relative to the file which calls it. You can use environmental variables such
|Anything others||Execute the line (first and other columns as one line) before
If the second column is
install, it will be ignored.
brew install package is same as
If you want to build macvim with lua option, you can write as above example
If you use
tap, Brew-file only does
tap the repository.
If you use
tapall, Brew-file does
brew install for all Formulae in the repository
in addition to do
tap the repository.
If you want to divide the list into several files.
If the top
then corresponding argument is used as an external file.
The path can be an absolute or a relative.
If you use a relative path, like .``/Brewfile2``,
then the start directory is the directory
where the main
You can use a nest of
The relative path starts from the parent file’s directory.
You can also use nested
though it should be no more than once in one Brewfile.
For the path, such
~ is translated into
and any environmental variables can be used.
You can also some shell variables:
$PLATFORM, which is platform identifier like
darwin, linux, or win32.
If you have:
Brewfile, and prepare files like:
Brewfile Host1.Brewfile Host2.Brewfile Host3.Brewfile
in the same directory,
brew-file picks up Host1.Brewfile for Host1,
and Host2.Brewfile for Host2, etc…
Or if you just have:
then you can put Host specific packages in ~/.Brewfile.
(If the file doesn’t exist,
brew-file just ignores it.)
Some packages such macvim has Application (MacVim.app).
If you want to install them to Applications area,
clean option, Brew-file runs cleanup.
By default, it just does dry run (no actual cleanup).
To run cleanup in non dry-run mode, use
If you want edit
If you do
brew file edit before installing
Brewfile and save w/o any modification,
you may make empty
Brewfile (Be careful,
brew -c -C remove all packages :scream:).
Therefore I recommend you to do
brew file -i at first if you don’t have
Manage Brewfile with Git¶
You can maintain your
Brewfile at the git repository.
First, make new repository at GitHub (or other git server),
which has a file named
Then, set the repository by:
$ brew file set_repo -r <repository>
It will clone the repository.
The content of
Brewfile in the repository will be used instead of
~/.config/brewfile/Brewfile will have this repository information.)
repository should be like rcmdnk/Brewfile in GitHub,
which should have
Brewfile (different file name can be used by
If you want to use other hosts than github, use full path for the repository, like:
$ brew file set_repo -r firstname.lastname@example.org:rcmdnk/my_brewfile
If the repository doesn’t have
Brewfile (or specified by
brew file init initialize the file.
Then, you can push it by
brew file push.
With this procedure, you can synchronize all your Mac easily :thumbsup:
To install new package, use:
$ brew file brew install <package>
brew install <package>, because above command
This is useful especially if you are using the repository for the
and want to use
brew file update.
Otherwise, please be careful to use
brew file update,
because it deletes what you installed, but you have not registered in
If you want to check your Apps for Cask, use:
$ brew file casklist
This command makes
Caskfile.txt, which is like:
### Cask applications ### Please copy these lines to your Brewfile and use with `brew bundle`. ### tap and install Cask (remove comment if necessary). #tap homebrew/cask #install brew-cask ### Apps installed by Cask in /Applications cask install adobe-reader # /Applications/Adobe Reader.app cask install xtrafinder # /Applications/XtraFinder.app ### Apps installed by Cask in /Applications/Utilities: cask install xquartz # /Applications/Utilities/XQuartz.app ### Apps installed by Cask in ~/Applications. cask install bettertouchtool.rb # ~/Applications/BetterTouchTool.app ############################# ### Apps not installed by Cask, but installed in /Applications. ### If you want to install them with Cask, remove comments. #cask install keyremap4macbook # /Applications/KeyRemap4MacBook.app ### Apps not installed by Cask, but installed in /Applications/Utilities: ### If you want to install them with Cask, remove comments. ### Apps not installed by Cask, but installed in ~/Applications. ### If you want to install them with Cask, remove comments. #cask install copy.rb # ~/Applications/Copy.app ############################# ### Apps not registered in Cask, but installed in /Applications. # /Applications/App Store.app # /Applications/Calendar.app ... ### Apps not registered in Cask, but installed in /Applications/Utilities: ... ### Apps not registered in Cask, but installed in ~/Applications.
You can find applications which were installed manually, but can be managed by Cask under “Apps not installed by Cask, but installed in…”.
If you want to manage them with
Brewfile, just copy above lines w/o “#” for these Apps.
Use machine specific Brewfile¶
You can share Brewfile at different machines by using Dropbox or Git repository Getting Started.
You may also want to have each machine specific packages.
In this case,
main command is useful.
First, make Brewfile with common packages:
tap homebrew/core brew bash brew neovim main ./Brewfile.$HOSTNAME
and share it for each machine.
Then, install packages at the machine A.
If you set brew-warp
brew file init,
new packages will be written into
in the same directory as
If you install packages at the machine B,
then new packages will be written into
If you have new packages which are common in
edit these files and move the packages into
If you want to have package lists for each platform,
it may useful to have
main command like:
This will make unique names like:
- macOS, M1 (arm environment):
- macOS, Intel or x86_64 environment at M1:
- Linux, 64 bit:
- Cygwin, 64 bit: