tips-n-tricks: misc. edits

This commit is contained in:
Alex Dunn 2015-08-28 09:10:10 -07:00
parent 859be3c948
commit fa1cc67e9f

View File

@ -1,20 +1,25 @@
# Tips N' Tricks # Tips N' Tricks
## Package versions
The preferred and supported method of installing specific versions of formulae is to use the [Homebrew-versions](https://github.com/Homebrew/homebrew-versions) tap. ## Installing previous versions of formulae
The preferred and supported method of installing specific versions of
formulae is to use the
[Homebrew-versions](https://github.com/Homebrew/homebrew-versions)
tap. If the version youre looking for isnt available, consider [opening a
pull request](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md)!
### Installing directly from pull-requests ### Installing directly from pull-requests
You can browse pull requests https://github.com/Homebrew/homebrew/pulls You can browse pull requests https://github.com/Homebrew/homebrew/pulls
and install through the direct link. For example Python 3.3.0 pull request https://github.com/Homebrew/homebrew/pull/15199 and install through the direct link. For example Python 3.3.0 pull request https://github.com/Homebrew/homebrew/pull/15199
```zsh ```sh
brew install https://raw.github.com/dsr/homebrew/9b22d42f50fcbc5e52c764448b3ac002bc153bd7/Library/Formula/python3.rb brew install https://raw.github.com/dsr/homebrew/9b22d42f50fcbc5e52c764448b3ac002bc153bd7/Library/Formula/python3.rb
``` ```
## Quickly remove something from /usr/local ## Quickly remove something from /usr/local
```bash ```sh
brew unlink $FORMULA brew unlink $FORMULA
``` ```
@ -22,19 +27,14 @@ This can be useful if a package can't build against the version of something you
And of course, you can simply `brew link $FORMULA` again afterwards! And of course, you can simply `brew link $FORMULA` again afterwards!
## Install into Homebrew without formulas ## Install into Homebrew without formulas
```bash ```sh
./configure --prefix=/usr/local/Cellar/foo/1.2 && make && make install && brew link foo ./configure --prefix=/usr/local/Cellar/foo/1.2 && make && make install && brew link foo
``` ```
## Command tab-completion ## Command tab-completion
### Bash ### Bash
Add to your `~/.bashrc` or `~/.bash_profile` (whichever you have configured to run on shell startup): Add to your `~/.bashrc` or `~/.bash_profile` (whichever you have configured to run on shell startup):
@ -42,7 +42,6 @@ Add to your `~/.bashrc` or `~/.bash_profile` (whichever you have configured to r
source $(brew --repository)/Library/Contributions/brew_bash_completion.sh source $(brew --repository)/Library/Contributions/brew_bash_completion.sh
``` ```
### Zsh ### Zsh
Run in terminal (may require `sudo`): Run in terminal (may require `sudo`):
@ -52,32 +51,39 @@ ln -s "$(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh" /usr/loca
## Pre-downloading a file for a formula ## Pre-downloading a file for a formula
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 45× the normal HTTP method. 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>. 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 45× the normal
HTTP method.
**New:** Download the file and drop it in `~/Library/Caches/Homebrew`, but
```bash watch the file name. Homebrew downloads files as <code>{{ formula
mv the_tarball `brew --cache formula-name` name }}-{{ version }}</code>. In the case of Erlang, this requires
``` renaming the file from <code>otp_src_R13B03</code> to
<code>erlang-R13B03</code>.
`brew -cache -s erlang` will print the correct name of the cached
download. This means instead of manually renaming a formula, you can
run `mv the_tarball $(brew --cache -s $FORMULA)`.
You can also pre-cache the download by using the command `brew fetch formula` which also displays the SHA1 and SHA256 values. This can be useful for updating formulae to new versions. You can also pre-cache the download by using the command `brew fetch formula` which also displays the SHA1 and SHA256 values. This can be useful for updating formulae to new versions.
## Using Homebrew behind a proxy ## 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`). 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: 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:
```bash
$ http_proxy=http://<proxyhost>:<proxyport> brew install $FORMULA
``` ```
http_proxy=http://<proxyhost>:<proxyport> brew install $FORMULA
```
### Proxy Authentication ### Proxy Authentication
```bash ```sh
$ http_proxy=http://<user>:<password>@<proxyhost>:<proxyport> brew install $FORMULA http_proxy=http://<user>:<password>@<proxyhost>:<proxyport> brew install $FORMULA
``` ```
**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. **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.
@ -90,7 +96,7 @@ $ http_proxy=http://<proxyhost>:<proxyport> sudo -E brew install $FORMULA
## Installing stuff without the Xcode-CLT ## Installing stuff without the Xcode-CLT
```bash ```sh
$ brew sh # or: eval $(brew --env) $ brew sh # or: eval $(brew --env)
$ gem install ronn # or c-programs $ gem install ronn # or c-programs
``` ```
@ -99,13 +105,13 @@ This imports the brew environment into your existing shell, gem will pick up the
## Install only a formula's dependencies (not the formula) ## Install only a formula's dependencies (not the formula)
``` ```sh
brew install --only-dependencies $FORMULA brew install --only-dependencies $FORMULA
``` ```
## brew irb ## Interactive Homebrew Shell
```bash ```sh
$ brew irb $ brew irb
1.8.7 :001 > Formula.factory("ace").methods - Object.methods 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] => [: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]
@ -114,7 +120,7 @@ $ brew irb
## Hiding the beer mug emoji when finishing a build ## Hiding the beer mug emoji when finishing a build
```bash ```sh
export HOMEBREW_NO_EMOJI=1 export HOMEBREW_NO_EMOJI=1
``` ```
@ -123,7 +129,7 @@ to hide all emoji.
The beer emoji can also be replaced with other character(s): The beer emoji can also be replaced with other character(s):
```bash ```sh
export HOMEBREW_INSTALL_BADGE="☕️ 🐸" export HOMEBREW_INSTALL_BADGE="☕️ 🐸"
``` ```