2017-01-04 10:53:21 +00:00
# Tips and Tricks
2014-10-26 14:54:36 +00:00
2015-08-28 09:10:10 -07:00
## Installing previous versions of formulae
2017-01-03 18:01:03 +00:00
The supported method of installing specific versions of
2019-01-08 19:13:46 +00:00
some formulae is to see if there is a versioned formula (e.g. `gcc@7` ) available. If the version you’ re looking for isn’ t available, consider using `brew extract` .
2014-10-26 14:54:36 +00:00
2017-03-25 22:53:33 -04:00
## Quickly remove something from `/usr/local`
2015-08-28 09:10:10 -07:00
```sh
2017-03-25 22:53:33 -04:00
brew unlink < formula >
2014-10-26 14:54:36 +00:00
```
This can be useful if a package can't build against the version of something you have linked into `/usr/local` .
2017-03-25 22:53:33 -04:00
And of course, you can simply `brew link <formula>` again afterwards!
2014-10-26 14:54:36 +00:00
2015-12-06 22:18:16 +00:00
## Install into Homebrew without formulae
2017-03-25 22:53:33 -04:00
2015-08-28 09:10:10 -07:00
```sh
2014-10-26 14:54:36 +00:00
./configure --prefix=/usr/local/Cellar/foo/1.2 & & make & & make install & & brew link foo
```
## Pre-downloading a file for a formula
2015-08-28 09:10:10 -07:00
Sometimes it's faster to download a file via means other than those
2018-10-05 17:23:22 -04:00
strategies that are available as part of Homebrew. For example,
2015-08-28 09:10:10 -07:00
Erlang provides a torrent that'll let you download at 4– 5× the normal
HTTP method.
2014-10-26 14:54:36 +00:00
2015-08-28 09:10:10 -07:00
Download the file and drop it in `~/Library/Caches/Homebrew` , but
2018-10-05 17:23:22 -04:00
watch the file name. Homebrew downloads files as `<formula>-<version>` .
2017-03-25 22:53:33 -04:00
In the case of Erlang, this requires renaming the file from `otp_src_R13B03` to
`erlang-R13B03` .
2014-10-26 14:54:36 +00:00
2015-11-26 14:56:04 -08:00
`brew --cache -s erlang` will print the correct name of the cached
2018-10-05 17:23:22 -04:00
download. This means instead of manually renaming a formula, you can
2017-03-25 22:53:33 -04:00
run `mv the_tarball $(brew --cache -s <formula>)` .
2014-10-26 14:54:36 +00:00
2018-10-05 17:23:22 -04:00
You can also pre-cache the download by using the command `brew fetch <formula>` which also displays the SHA-256 hash. This can be useful for updating formulae to new versions.
2014-10-26 14:54:36 +00:00
2017-03-18 17:45:12 -04:00
## Installing stuff without the Xcode CLT
2017-03-25 22:53:33 -04:00
2015-08-28 09:10:10 -07:00
```sh
2017-03-25 22:53:33 -04:00
brew sh # or: eval $(brew --env)
gem install ronn # or c-programs
2014-10-26 14:54:36 +00:00
```
2017-03-25 22:53:33 -04:00
This imports the `brew` environment into your existing shell; `gem` will pick up the environment variables and be able to build. As a bonus `brew` 's automatically determined optimization flags are set.
2014-10-26 14:54:36 +00:00
## Install only a formula's dependencies (not the formula)
2017-03-25 22:53:33 -04:00
2015-08-28 09:10:10 -07:00
```sh
2017-03-25 22:53:33 -04:00
brew install --only-dependencies < formula >
2014-10-26 14:54:36 +00:00
```
2015-08-28 09:10:10 -07:00
## Interactive Homebrew Shell
2017-03-25 22:53:33 -04:00
2015-08-28 09:10:10 -07:00
```sh
2014-10-26 14:54:36 +00:00
$ brew irb
1.8.7 :001 > Formula.factory("ace").methods - Object.methods
2020-09-03 10:34:22 +01:00
=> [:install, :path, :homepage, :downloader, :stable, :bottle, :head, :active_spec, :buildpath, :ensure_specs_set, :url, :version, :specs, :mirrors, :installed?, :explicitly_requested?, :linked_keg, :installed_prefix, :prefix, :rack, :bin, :doc, :include, :info, :lib, :libexec, :man, :man1, :man2, :man3, :man4, :man5, :man6, :man7, :man8, :sbin, :share, :etc, :var, :plist_name, :plist_path, :download_strategy, :cached_download, :caveats, :options, :patches, :keg_only?, :fails_with?, :skip_clean?, :brew, :std_cmake_args, :deps, :external_deps, :recursive_deps, :system, :fetch, :verify_download_integrity, :fails_with_llvm, :fails_with_llvm?, :std_cmake_parameters, :mkdir, :mktemp]
2014-10-26 14:54:36 +00:00
1.8.7 :002 >
```
## Hiding the beer mug emoji when finishing a build
2017-03-25 22:53:33 -04:00
2015-08-28 09:10:10 -07:00
```sh
2014-10-26 14:54:36 +00:00
export HOMEBREW_NO_EMOJI=1
```
2018-10-05 17:23:22 -04:00
This sets the `HOMEBREW_NO_EMOJI` environment variable, causing Homebrew
2015-08-28 08:58:11 -07:00
to hide all emoji.
The beer emoji can also be replaced with other character(s):
2015-08-28 09:10:10 -07:00
```sh
2015-08-28 08:58:11 -07:00
export HOMEBREW_INSTALL_BADGE="☕️ 🐸"
```
2014-10-26 14:54:36 +00:00
2015-08-28 08:56:09 -07:00
## Editor plugins
2014-10-26 14:54:36 +00:00
2015-08-28 08:56:09 -07:00
### Sublime Text
2015-03-28 22:19:56 +08:00
2015-08-28 08:56:09 -07:00
In Sublime Text 2/3, you can use Package Control to install
[Homebrew-formula-syntax ](https://github.com/samueljohn/Homebrew-formula-syntax ),
which adds highlighting for inline patches.
2015-03-28 22:19:56 +08:00
2015-08-28 08:56:09 -07:00
### Vim
[brew.vim ](https://github.com/xu-cheng/brew.vim ) adds highlighting to
inline patches in Vim.
### Emacs
[homebrew-mode ](https://github.com/dunn/homebrew-mode ) provides syntax
highlighting for inline patches as well as a number of helper functions
for editing formula files.
2016-08-15 18:41:22 -05:00
2016-09-27 15:33:39 +08:00
[pcmpl-homebrew ](https://github.com/hiddenlotus/pcmpl-homebrew ) provides completion
for emacs shell-mode and eshell-mode.
2016-08-15 18:41:22 -05:00
### Atom
[language-homebrew-formula ](https://atom.io/packages/language-homebrew-formula )
adds highlighting and diff support (with the
[language-diff ](https://atom.io/packages/language-diff ) plugin).