2014-10-26 14:54:36 +00:00
# Tips N' Tricks
2015-08-28 09:10:10 -07:00
## Installing previous versions of formulae
The preferred and supported method of installing specific versions of
2017-01-02 18:29:00 +00:00
formulae is to use formula like e.g. `gcc@6` . If the version you’ re looking for isn’ t available, consider [opening a
2016-09-19 20:20:08 +01:00
pull request](https://github.com/Homebrew/brew/blob/master/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md)!
2014-10-26 14:54:36 +00:00
### Installing directly from pull-requests
2016-04-03 14:03:33 +01:00
You can browse pull requests https://github.com/Homebrew/homebrew-core/pulls
2014-10-26 14:54:36 +00:00
and install through the direct link. For example Python 3.3.0 pull request https://github.com/Homebrew/homebrew/pull/15199
2015-08-28 09:10:10 -07:00
```sh
2014-10-26 14:54:36 +00:00
brew install https://raw.github.com/dsr/homebrew/9b22d42f50fcbc5e52c764448b3ac002bc153bd7/Library/Formula/python3.rb
```
## Quickly remove something from /usr/local
2015-08-28 09:10:10 -07:00
```sh
2014-10-26 14:54:36 +00:00
brew unlink $FORMULA
```
This can be useful if a package can't build against the version of something you have linked into `/usr/local` .
And of course, you can simply `brew link $FORMULA` again afterwards!
2015-11-04 12:59:45 -05:00
## Activate a previously installed version of a formula
```sh
brew info $FORMULA
brew switch $FORMULA $VERSION
```
Use `brew info $FORMULA` to check what versions are installed but not currently activated, then `brew switch $FORMULA $VERSION` to activate the desired version. This can be useful if you would like to switch between versions of a formula.
2015-12-06 22:18:16 +00:00
## Install into Homebrew without formulae
2014-10-26 14:54:36 +00: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
strategies that are available as part of Homebrew. For example,
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
watch the file name. Homebrew downloads files as < code > {{ formula
name }}-{{ version }}< / code > . In the case of Erlang, this requires
renaming the file from < code > otp_src_R13B03< / code > to
< code > erlang-R13B03< / code > .
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
2015-08-28 09:10:10 -07:00
download. This means instead of manually renaming a formula, you can
run `mv the_tarball $(brew --cache -s $FORMULA)` .
2014-10-26 14:54:36 +00:00
2016-03-19 20:54:36 +01:00
You can also pre-cache the download by using the command `brew fetch formula` which also displays the SHA256 value. This can be useful for updating formulae to new versions.
2014-10-26 14:54:36 +00:00
## Using Homebrew behind a proxy
Behind the scenes, Homebrew uses several commands for downloading files (e.g. curl, git, svn). Many of these tools can download via a proxy. It's a common (though not universal) convention for these command-line tools to observe getting the proxy parameters from environment variables (e.g. `http_proxy` ). Unfortunately, most tools are inconsistent in their use of these environment parameters (e.g. curl supports `http_proxy` , `HTTPS_PROXY` , `FTP_PROXY` , `GOPHER_PROXY` , `ALL_PROXY` , `NO_PROXY` ).
2015-08-28 09:10:10 -07:00
Luckily, for the majority of cases setting `http_proxy` is enough.
You can set this environment variable in several ways (search on the
internet for details), including at runtime:
2014-10-26 14:54:36 +00:00
```
2015-08-28 09:10:10 -07:00
http_proxy=http://< proxyhost > :< proxyport > brew install $FORMULA
```
2014-10-26 14:54:36 +00:00
### Proxy Authentication
2015-08-28 09:10:10 -07:00
```sh
http_proxy=http://< user > :< password > @< proxyhost > :< proxyport > brew install $FORMULA
2014-10-26 14:54:36 +00:00
```
## Installing stuff without the Xcode-CLT
2015-08-28 09:10:10 -07:00
```sh
2014-10-26 14:54:36 +00:00
$ brew sh # or: eval $(brew --env)
$ gem install ronn # or c-programs
```
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.
## Install only a formula's dependencies (not the formula)
2015-08-28 09:10:10 -07:00
```sh
2014-10-26 14:54:36 +00:00
brew install --only-dependencies $FORMULA
```
2015-08-28 09:10:10 -07:00
## Interactive Homebrew Shell
2014-10-26 14:54:36 +00: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
=> [:install, :path, :homepage, :downloader, :stable, :bottle, :devel, :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]
1.8.7 :002 >
```
## Hiding the beer mug emoji when finishing a build
2015-08-28 09:10:10 -07:00
```sh
2014-10-26 14:54:36 +00:00
export HOMEBREW_NO_EMOJI=1
```
2015-08-28 08:58:11 -07:00
This sets the HOMEBREW_NO_EMOJI environment variable, causing Homebrew
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).