-
Notifications
You must be signed in to change notification settings - Fork 0
Tips N' Tricks
show and switch
brew versions python3
3.2.3 git checkout 83b3771 /usr/local/Library/Formula/python3.rb
3.2.2 git checkout f3408c9 /usr/local/Library/Formula/python3.rb
3.2.1 git checkout 949d521 /usr/local/Library/Formula/python3.rb
3.2 git checkout 83ed494 /usr/local/Library/Formula/python3.rb
...
brew switch python3 3.2.2
You can browse pull requests https://github.com/mxcl/homebrew/pulls and install through the direct link. For example Python 3.3.0 pull request https://github.com/mxcl/homebrew/pull/15199
brew install https://raw.github.com/dsr/homebrew/9b22d42f50fcbc5e52c764448b3ac002bc153bd7/Library/Formula/python3.rb
brew unlink foo
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 foo
again afterwards!
./configure --prefix=/usr/local/Cellar/foo/1.2 && make && make install && brew link foo
Add to your ~/.bashrc
or ~/.bash_profile
(whichever you have configured to run on shell startup):
source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
Run in terminal:
mkdir -p ~/.zsh/func
ln -s "$(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh" ~/.zsh/func/_brew
Add to your ~/.zshrc
:
fpath=($HOME/.zsh/func $fpath)
typeset -U fpath
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. Download the file and drop it in ~/Library/Caches/Homebrew
, but watch the file name. Homebrew downloads files as {{ formula name }}-{{ version }}
. In the case of Erlang, this requires renaming the file from otp_src_R13B03
to erlang-R13B03
.
New:
mv the_tarball `brew --cache formula-name`
You can also pre-cache the download by using the command brew fetch formula
which also displays the MD5. This can be useful for updating formulae to new versions.
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
).
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), but the way I prefer is:
$ http_proxy=http://<proxyhost>:<proxyport> brew install foo
$ http_proxy=http://<user>:<password>@<proxyhost>:<proxyport> brew install foo
NB: this technique will also work if you prefer to use sudo
with Homebrew. But as sudo
clears the environment before executing Homebrew, your proxy settings may get lost.
Workaround:
$ http_proxy=http://<proxyhost>:<proxyport> sudo -E brew install foo
$ 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.
brew install `brew deps foo`
$ 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 >
export HOMEBREW_NO_EMOJI=1
This sets the HOMEBREW_NO_EMOJI environment variable, causing homebrew to hide all emoji.