Update Tips-N'-Tricks.md

This commit is contained in:
EricFromCanada 2021-11-14 21:13:07 -05:00
parent 66830f9d17
commit fd0ae2bd5c
No known key found for this signature in database
GPG Key ID: 179D9CDDDB814168

View File

@ -1,9 +1,8 @@
# Tips and Tricks
## Installing previous versions of formulae
## Install previous versions of formulae
The supported method of installing specific versions of
some formulae is to see if there is a versioned formula (e.g. `gcc@7`) available. If the version youre looking for isnt available, consider using `brew extract`.
Some formulae in `homebrew/core` are made available as [versioned formulae](Versions.md) using a special naming format, e.g. `gcc@7`. If the version you're looking for isn't available, consider using `brew extract`.
## Quickly remove something from Homebrew's prefix
@ -15,32 +14,22 @@ 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!
## Pre-downloading a file for a formula
## Pre-download 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.
Sometimes it's faster to download a file via means other than the strategies that are available as part of Homebrew. For example, Erlang provides a torrent that'll let you download at 45× compared to the normal HTTP method.
Download the file and drop it in `~/Library/Caches/Homebrew`, but
watch the file name. Homebrew downloads files as `<formula>-<version>`.
In the case of Erlang, this requires renaming the file from `otp_src_R13B03` to
`erlang-R13B03`.
`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>)"`.
Downloads are saved in the `downloads` subdirectory of Homebrew's cache directory (as specified by `brew --cache`, e.g. `~/Library/Caches/Homebrew`) and renamed as `<url-hash>--<formula>-<version>`. The command `brew --cache -s <formula>` will print the expected path of the cached download, so after downloading the file, you can run `mv the_tarball "$(brew --cache -s <formula>)"` to relocate it to the cache.
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.
## Installing stuff without the Xcode CLT
## Install stuff without the Xcode CLT
```sh
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.
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)
@ -48,23 +37,27 @@ This imports the `brew` environment into your existing shell; `gem` will pick up
brew install --only-dependencies <formula>
```
## Interactive Homebrew Shell
## Use the interactive Homebrew shell
```sh
$ brew irb
1.8.7 :001 > Formula.factory("ace").methods - Object.methods
=> [: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]
1.8.7 :002 >
==> Interactive Homebrew Shell
Example commands available with: `brew irb --examples`
irb(main):001:0> Formulary.factory("ace").methods - Object.methods
=> [:install, :test, :test_defined?, :sbin, :pkgshare, :elisp,
:frameworks, :kext_prefix, :any_version_installed?, :etc, :pkgetc,
...
:on_macos, :on_linux, :debug?, :quiet?, :verbose?, :with_context]
irb(main):002:0>
```
## Hiding the beer mug emoji when finishing a build
## Hide the beer mug emoji when finishing a build
```sh
export HOMEBREW_NO_EMOJI=1
```
This sets the `HOMEBREW_NO_EMOJI` environment variable, causing Homebrew
to hide all emoji.
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):
@ -76,26 +69,18 @@ export HOMEBREW_INSTALL_BADGE="☕️ 🐸"
### Sublime Text
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.
- [Homebrew-formula-syntax](https://github.com/samueljohn/Homebrew-formula-syntax) can be installed with Package Control in Sublime Text 2/3, which adds highlighting for inline patches.
### Vim
[brew.vim](https://github.com/xu-cheng/brew.vim) adds highlighting to
inline patches in 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.
- [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.
[pcmpl-homebrew](https://github.com/hiddenlotus/pcmpl-homebrew) provides completion
for emacs shell-mode and eshell-mode.
- [pcmpl-homebrew](https://github.com/hiddenlotus/pcmpl-homebrew) provides completion for emacs shell-mode and eshell-mode.
### 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).
- [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).