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.
- What is Brew-file?
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.
brew file help for the basic usage.
If you have installed
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
|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
|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
Brewfile is a core part of Brew-file. This file is normally located in /usr/local/Library/Brewfile.
This can be changed by
or set it in your setting file (such .bashrc) like:
$ export HOMEBREW_BREWFILE=~/.brewfile
A basic Brewfile is like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
The format is
command <package> [<options>] for each line.
The line starting with
# is comment line.
Available commands in Brewfile are as follows:
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
push the repository by
brew file pull/
brew file push, respectively.
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.
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…)
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
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.
brew file update does
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.
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
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 file initialize is automatically executed
brew install command.
To enable this wrapper function, source this file in your setting file such .bashrc:
1 2 3
brew wrapper function executes original
brew file command is not available
so that you can safely uninstall/re-install brew-file.