homebrew-cask/USAGE.md

220 lines
8.3 KiB
Markdown
Raw Normal View History

2016-01-11 20:00:37 +08:00
# How to Use Homebrew-Cask
## Getting Started
2015-09-07 21:33:37 +08:00
First ensure you have Homebrew version `0.9.5` or higher:
```bash
$ brew --version
0.9.5
```
## Frequently Used Commands
2013-11-10 21:36:03 +08:00
2016-01-11 20:00:37 +08:00
Homebrew-Cask is implemented as a subcommand of Homebrew. All Homebrew-Cask commands begin with `brew cask`. Homebrew-Cask has its own set of command verbs many of which are similar to Homebrews. The most frequently-used
commands are:
2013-12-16 05:08:27 +08:00
2015-09-07 21:33:37 +08:00
* `search` — searches all known Casks
* `install` — installs the given Cask
* `uninstall` — uninstalls the given Cask
2013-12-16 05:08:27 +08:00
## Searching for Casks
2013-12-16 05:08:27 +08:00
2015-09-16 06:24:11 +08:00
The `brew cask search` command accepts a series of substring arguments, and returns tokens representing matching Casks. Lets see if theres a Cask for Google Chrome:
2013-12-16 05:08:27 +08:00
```bash
$ brew cask search chrome
google-chrome
```
2013-11-10 21:36:03 +08:00
A `search` command with no search term will list all available Casks:
```bash
$ brew cask search
# <list of all available Casks>
```
## Installing Casks
2015-09-16 06:24:11 +08:00
The command `brew cask install` accepts a Cask token as returned by `brew cask search`. Lets try to install Google Chrome:
```bash
$ brew cask install google-chrome
==> Downloading https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg
==> Moving App 'Google Chrome.app' to '/Applications/Google Chrome.app'
🍺 google-chrome was successfully installed!
```
## Uninstalling Casks
Easy peasy:
```bash
$ brew cask uninstall google-chrome
```
[WIP] Change artifact behavior to moving instead of symlinking (#13966) * Change app artifact to move instead of link First step towards change in installation behavior mentioned in [13201] * Fix handling of binaries linked from inside of app bundles Also adds `appdir` method for interpolation in stanzas * Change appdir to root Applications directory * Update 2-app tests * Refactor: add options, ivars to `Installer`, `Download` In preparation for upcoming changes, this commit cleans up some code. The commit includes: - In order to reduce unnecessary object passing, make both the `force` and `skip_cask_deps` option into instance variables of the `Installer` class - Introduce options hashes to initializers of both the `Installer` and `Download` class - When the `install --force` command enters the fetch phase, make it explicit in the code that fetching is never enforced in that case. - Update tests * Force overwrite artifacts on `--force` reinstall This commit changes the behavior of a `Moved` artifact such that if the target already exists, `brew cask install --force` will remove the existing target before moving the staged artifact. In that case, the warning message will say *overwriting* instead of *not moving*. The behavior of plain `brew cask install` remains unchanged; the same goes for the warning message for that case. * Change remaining artifacts to move instead of symlink * Update casks to use appdir in binary paths * Forcibly overwrite artifacts, modifying flags and using `sudo` if needed - This commit implements [the proposed behavior for `install --force`](https://github.com/caskroom/homebrew-cask/pull/13966#issuecomment-220830387) when a target already exists and has either permission problems or is not owned by the user. - The changes apply only when the `force` option is given. - Reused the existing safeguard from the `.pkg` artifact to prevent deleting important directories by bug or mistake - The two existing blacklists `SYSTEM_DIRS` and `UNDELETABLE_DIRS` have been consolidated into the `Hbc::MacOS` module. - `UNDELETABLE_DIRS` now also contains all the entries from `SYSTEM_DIRS` which was a to-do anyway. - The two blacklists are now also frozen for good measure. - The utility method `permissions_rmtree` was moved to `Hbc::Utils`. - The `tried_permissions` part in `Utils` now falls back correctly when there are also ownership issues at the same time. - Introduced a separate `current_user` method for mocking. - Added an optional feature to `FakeSystemCommand` so it can now act as a proxy to `SystemCommand`. - Added tests for various `permissions_rmtree` cases.
2016-06-01 03:23:21 +08:00
This will both uninstall the Cask and remove applications which were moved to `/Applications`.
To uninstall all versions of a Cask, use `--force`:
```bash
$ brew cask uninstall --force google-chrome
```
2015-09-16 06:24:11 +08:00
Note that `uninstall --force` is currently imperfect. See the man page for more information.
## Other Commands
2015-09-07 21:33:37 +08:00
* `info` — displays information about the given Cask
* `list` — with no args, lists installed Casks; given installed Casks, lists staged files (with `--full-name`, include tap name)
* `fetch` — downloads remote application files for the given Cask to the local cache (with `--force`, re-download even if already cached)
2015-09-07 21:33:37 +08:00
* `doctor` — checks for configuration issues
* `cleanup` — cleans up cached downloads (with `--outdated`, only cleans old downloads)
2016-01-11 20:00:37 +08:00
* `home` — opens the homepage of the given Cask; or with no arguments, the Homebrew-Cask project page
* `zap` — try to remove *all* files associated with a Cask (may include resources shared with other applications)
The following commands are for Cask authors:
2015-09-07 21:33:37 +08:00
* `audit` — verifies installability of Casks
* `cat` — dumps the given Cask to the standard output
* `create` — creates a Cask and opens it in an editor
* `edit` — edits the given Cask
The following aliases and abbreviations are provided for convenience:
2015-09-07 21:33:37 +08:00
* `ls``list`
* `-S``search`
* `rm`, `remove``uninstall`
* `dr``doctor`
2015-10-23 12:29:12 +08:00
## Tab Completion
[Homebrew/homebrew-completions](https://github.com/Homebrew/homebrew-completions) supports `bash` and `fish` completions (only for `brew-cask` right now). Install them with:
```bash
$ brew install brew-cask-completion
2015-10-23 12:29:12 +08:00
```
For `zsh` completion support, simply run:
```bash
$ brew install zsh-completions
2015-10-23 12:29:12 +08:00
```
## Inspecting Installed Casks
2016-01-11 20:00:37 +08:00
List all installed Casks:
```bash
$ brew cask list
atom google-chrome 1password
```
Show details about a specific Cask:
```bash
$ brew cask info caffeine
caffeine: 1.1.1
http://lightheadsw.com/caffeine/
Not installed
2016-08-15 07:35:03 +08:00
From: https://github.com/caskroom/homebrew-cask/blob/master/Casks/caffeine.rb
==> Name
Caffeine
==> Artifacts
Caffeine.app (app)
```
## Updating/Upgrading Casks
2016-01-11 20:00:37 +08:00
Since the Homebrew-Cask repository is a Homebrew Tap, youll pull down the latest Casks every time you issue the regular Homebrew command `brew update`. Currently, Homebrew-Cask cannot always detect if an application has been updated. You can force an update via the command `brew cask install --force`. We are working on improving this.
2016-01-11 20:00:37 +08:00
It is generally safe to run updates from within an application.
2016-01-11 20:00:37 +08:00
## Updating/Upgrading the Homebrew-Cask Tool
Homebrew [automatically taps and keeps Homebrew-Cask updated](https://github.com/caskroom/homebrew-cask/pull/15381). `brew update` is all that is required.
## Additional Taps (optional)
2016-01-11 20:00:37 +08:00
The primary Homebrew-Cask Tap includes most of the Casks that a typical user will be interested in. There are a few additional Taps where we store different kinds of Casks.
| Tap name | description |
| -------- | ----------- |
2016-02-19 23:37:25 +08:00
| [caskroom/versions](https://github.com/caskroom/homebrew-versions) | contains alternate versions of Casks (e.g. betas, nightly releases, old versions)
| [caskroom/fonts](https://github.com/caskroom/homebrew-fonts) | contains Casks that install fonts
2016-02-20 23:55:39 +08:00
| [caskroom/eid](https://github.com/caskroom/homebrew-eid) | contains Casks that install electronic identity card software of various countries
2017-04-02 20:50:50 +08:00
| [caskroom/drivers](https://github.com/caskroom/homebrew-drivers) | contains Casks that install drivers for various devices
You can tap any of the above with a `brew tap` command:
```bash
$ brew tap <tap_name>
```
2015-09-16 06:24:11 +08:00
after which, Casks from the new Tap will be available to `search` or `install` just like Casks from the main Tap. `brew update` will automatically keep your new Tap up to date.
2015-09-16 04:47:35 +08:00
You may also specify a fully-qualified Cask token (which includes the Tap) for any `brew cask` command. This will implicitly add the Tap if you have not previously added it with `brew tap`:
```bash
$ brew cask install caskroom/fonts/font-symbola
```
## Options
2014-01-06 04:30:53 +08:00
`brew cask` accepts a number of options:
* `--version`: print version and exit
* `--debug`: output debug information
* `--no-binaries`: skip symlinking executable binaries into `/usr/local/bin`
* `--require-sha`: abort installation of cask if no checksum is defined
* `--language=<iso-language>[,<iso-language> ... ]` changes the language of the cask to be installed. The first matching language is used, otherwise it uses the default language of the cask.
2014-01-06 04:30:53 +08:00
You can also modify the default installation locations used when issuing `brew cask install`:
* `--appdir=/my/path` changes the path where the applications will be moved. Default is `/Applications`.
* `--fontdir=/my/path` changes the path for Fonts. Default is `~/Library/Fonts`.
* See `man brew-cask` for the other default installation locations and the flags to change them.
2014-01-28 23:17:50 +08:00
To make these settings persistent, you might want to add the following line to your `.bash_profile` or `.zshenv`:
```bash
2013-12-14 17:10:50 +08:00
# Specify your defaults in this environment variable
export HOMEBREW_CASK_OPTS="--appdir=~/Applications --fontdir=/Library/Fonts"
```
2015-09-16 06:24:11 +08:00
Note that you still can override the environment variable `HOMEBREW_CASK_OPTS` by _explicitly_ providing options in the command line:
```bash
# Will force the Chrome app to be moved to /Applications
[WIP] Change artifact behavior to moving instead of symlinking (#13966) * Change app artifact to move instead of link First step towards change in installation behavior mentioned in [13201] * Fix handling of binaries linked from inside of app bundles Also adds `appdir` method for interpolation in stanzas * Change appdir to root Applications directory * Update 2-app tests * Refactor: add options, ivars to `Installer`, `Download` In preparation for upcoming changes, this commit cleans up some code. The commit includes: - In order to reduce unnecessary object passing, make both the `force` and `skip_cask_deps` option into instance variables of the `Installer` class - Introduce options hashes to initializers of both the `Installer` and `Download` class - When the `install --force` command enters the fetch phase, make it explicit in the code that fetching is never enforced in that case. - Update tests * Force overwrite artifacts on `--force` reinstall This commit changes the behavior of a `Moved` artifact such that if the target already exists, `brew cask install --force` will remove the existing target before moving the staged artifact. In that case, the warning message will say *overwriting* instead of *not moving*. The behavior of plain `brew cask install` remains unchanged; the same goes for the warning message for that case. * Change remaining artifacts to move instead of symlink * Update casks to use appdir in binary paths * Forcibly overwrite artifacts, modifying flags and using `sudo` if needed - This commit implements [the proposed behavior for `install --force`](https://github.com/caskroom/homebrew-cask/pull/13966#issuecomment-220830387) when a target already exists and has either permission problems or is not owned by the user. - The changes apply only when the `force` option is given. - Reused the existing safeguard from the `.pkg` artifact to prevent deleting important directories by bug or mistake - The two existing blacklists `SYSTEM_DIRS` and `UNDELETABLE_DIRS` have been consolidated into the `Hbc::MacOS` module. - `UNDELETABLE_DIRS` now also contains all the entries from `SYSTEM_DIRS` which was a to-do anyway. - The two blacklists are now also frozen for good measure. - The utility method `permissions_rmtree` was moved to `Hbc::Utils`. - The `tried_permissions` part in `Utils` now falls back correctly when there are also ownership issues at the same time. - Introduced a separate `current_user` method for mocking. - Added an optional feature to `FakeSystemCommand` so it can now act as a proxy to `SystemCommand`. - Added tests for various `permissions_rmtree` cases.
2016-06-01 03:23:21 +08:00
# even though HOMEBREW_CASK_OPTS specified ~/Applications
$ brew cask install --appdir="/Applications" google-chrome
```
2016-01-11 20:00:37 +08:00
## Advanced Searching
2015-09-16 06:24:11 +08:00
The default search algorithm is a lax substring approach, which does not use the command-line arguments exactly as given. If you need to specify a search more precisely, a single search argument enclosed in `/` characters will be taken as a Ruby regular expression:
```bash
$ brew cask search '/^google.c[a-z]rome$/'
google-chrome
```
## Other Ways to Specify a Cask
2015-09-16 06:24:11 +08:00
Most `brew cask` commands can accept a Cask token as an argument. As described above, the token on the command line can take the form of:
2015-09-16 06:24:11 +08:00
* A token as returned by `brew cask search`, _eg_: `google-chrome`.
* A fully-qualified token which includes the Tap, _eg_: `caskroom/fonts/font-symbola`.
2016-01-11 20:00:37 +08:00
`brew cask` also accepts three other forms as arguments:
* A path to a Cask file, _eg_: `/usr/local/Library/Taps/caskroom/homebrew-cask/Casks/google-chrome.rb`.
* A `curl`-retrievable URI to a Cask file, _eg_: `https://raw.githubusercontent.com/caskroom/homebrew-cask/f25b6babcd398abf48e33af3d887b2d00de1d661/Casks/google-chrome.rb`.
2015-09-16 06:24:11 +08:00
* A file in the current working directory, _eg_: `my-modfied-google-chrome.rb`. Note that matching Tapped Cask tokens will be preferred over this form when there is a conflict. To force the use of a Cask file in the current directory, specify a pathname with slashes, _eg_: `./google-chrome.rb`.
The last three forms are intended for users who wish to maintain private Casks.
## Taps
2015-09-16 06:24:11 +08:00
You can add Casks to your existing (or new) Taps: just create a directory named `Casks` inside your Tap, put your Cask files there, and everything will just work.