homebrew-cask/USAGE.md

196 lines
8.0 KiB
Markdown
Raw Normal View History

# How to Use Homebrew Cask
## Frequently Used Commands
2013-11-10 21:36:03 +08:00
2023-09-12 02:05:20 +08:00
Homebrew Cask is implemented as part of [Homebrew](https://brew.sh). All Homebrew Cask commands begin with `brew`, which works for both casks and formulae. The most frequently-used commands are:
2013-12-16 05:08:27 +08:00
2023-09-12 02:09:44 +08:00
* `install --cask` — installs the given cask.
* `uninstall --cask` — uninstalls the given cask.
* `reinstall --cask` — reinstalls the given cask.
* `list --cask` — lists installed casks.
2013-12-16 05:08:27 +08:00
## Searching for Casks
2013-12-16 05:08:27 +08:00
2023-09-12 02:11:36 +08:00
To search for casks, use `brew search`. Lets see if theres a cask for Google Chrome:
2013-12-16 05:08:27 +08:00
2023-09-12 02:09:44 +08:00
```console
$ brew search --cask google-chrome
==> Casks
2020-11-11 19:12:59 +08:00
google-chrome google-chrome-beta google-chrome-canary google-chrome-dev
```
## Installing Casks
2023-09-12 02:09:44 +08:00
The command `brew install --cask` accepts one or multiple cask tokens. Lets try to install Google Chrome:
2023-09-12 02:09:44 +08:00
```console
$ brew install --cask google-chrome
==> Downloading https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg
2020-11-11 19:12:59 +08:00
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'google-chrome'.
==> Installing Cask google-chrome
==> Moving App 'Google Chrome.app' to '/Applications/Google Chrome.app'.
🍺 google-chrome was successfully installed!
```
## Uninstalling Casks
Easy peasy:
2023-09-12 02:09:44 +08:00
```console
$ brew uninstall --cask google-chrome
```
2023-09-12 02:11:36 +08:00
This will both uninstall the cask and remove the applications that were moved to `/Applications`.
## Other Commands
2023-09-12 02:09:44 +08:00
Unless noted, these are run with `--cask <cask_token>` to apply to Homebrew Cask.
2023-09-12 02:09:44 +08:00
* `info` — displays information about the given cask.
* `fetch` — downloads remote application files for the given cask to the local cache (with `--force`, re-downloads even if already cached).
* `--cache` — displays the expected path to Homebrew's local cache of application files.
* `doctor` — checks for configuration issues (run with no arguments).
* `style` — checks style for the given cask using RuboCop.
* `home` — opens the homepage of the given cask; or with no arguments, the Homebrew project page.
* `uninstall --zap` — try to remove *all* files associated with a cask (may include resources shared with other applications).
* `outdated` — lists all outdated casks (run with just `--cask`).
* `upgrade` — updates all outdated casks (run with just `--cask`).
2023-09-12 02:09:44 +08:00
The following commands are for cask authors:
* `audit` — verifies installability of casks.
* `cat` — dumps the given cask to the standard output.
* `create --cask` — 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`
2020-11-11 19:12:59 +08:00
* `abv``info`
* `homepage``home`
2015-10-23 12:29:12 +08:00
## Tab Completion
2023-09-12 02:09:44 +08:00
Homebrew comes with `bash`, `zsh` and `fish` tab completion for the `brew` command. See [`brew` Shell Completion](https://docs.brew.sh/Shell-Completion) for more information.
2015-10-23 12:29:12 +08:00
2023-09-12 02:09:44 +08:00
## Inspecting Installed Casks
2015-10-23 12:29:12 +08:00
2023-09-12 02:09:44 +08:00
List staged files for an installed cask:
2015-10-23 12:29:12 +08:00
2023-09-12 02:09:44 +08:00
```console
$ brew list --cask firefox
==> App
/Applications/Firefox.app (112 files, 360MB)
2015-10-23 12:29:12 +08:00
```
2023-09-12 02:09:44 +08:00
List all installed casks:
2023-09-12 02:09:44 +08:00
```console
$ brew list --cask
firefox google-chrome opera
```
2023-09-12 02:09:44 +08:00
With `--full-name` any external tap names will also be included, _e.g._: `purple/monkey/dishwasher` for the cask `dishwasher` installed from the tap `purple/monkey`.
2020-11-11 19:12:59 +08:00
2023-09-12 02:09:44 +08:00
Show details about a specific cask:
2020-11-11 19:12:59 +08:00
2023-09-12 02:09:44 +08:00
```console
2020-11-11 19:12:59 +08:00
$ brew info keepingyouawake
2023-09-12 02:09:44 +08:00
==> keepingyouawake: 1.6.4 (auto_updates)
2020-11-11 19:12:59 +08:00
https://keepingyouawake.app/
2023-09-12 02:09:44 +08:00
/usr/local/Caskroom/keepingyouawake/1.6.4 (129B)
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/k/keepingyouawake.rb
2016-08-15 07:35:03 +08:00
==> Name
2020-11-11 19:12:59 +08:00
KeepingYouAwake
==> Description
2023-09-12 02:09:44 +08:00
Tool to prevent the system from going into sleep mode
2016-08-15 07:35:03 +08:00
==> Artifacts
2020-11-11 19:12:59 +08:00
KeepingYouAwake.app (App)
```
## Updating/Upgrading Casks
2023-09-12 02:11:36 +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`. You can check for outdated casks with `brew outdated` and install the outdated casks with `brew upgrade`. Many applications update themselves, so their casks are ignored by `brew outdated` and `brew upgrade`. This behaviour can be overridden by adding `--greedy` to either command.
## Updating/Upgrading the Homebrew Cask Tool
Homebrew [automatically taps and keeps Homebrew Cask updated](https://github.com/Homebrew/homebrew-cask/pull/15381). `brew update` is all that is required.
## Additional Tap (optional)
The primary Homebrew Cask tap includes most of the casks that a typical user will be interested in. There is an additional tap where we store different fonts as casks.
2023-09-12 02:11:36 +08:00
| tap name | description |
| -------- | ----------- |
2023-09-12 02:11:36 +08:00
| [homebrew/cask-fonts](https://github.com/Homebrew/homebrew-cask-fonts) | contains casks that install fonts
You can tap the above with the `brew tap` command:
```bash
brew tap homebrew/cask-fonts
```
2023-09-12 02:11:36 +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.
2023-09-12 02:11:36 +08:00
You may also specify a fully-qualified cask token (which includes the tap) for any `brew` command. This will implicitly add the tap if you have not previously added it with `brew tap`:
```bash
2023-09-12 02:09:44 +08:00
brew install homebrew/cask-fonts/font-symbola
```
## Options
2020-11-11 19:12:59 +08:00
`brew` accepts a number of options:
2014-01-06 04:30:53 +08:00
* `--version`: print version and exit.
* `--debug`: output debug information.
* `--no-binaries`: skip symlinking executable binaries into `/usr/local/bin`.
2023-09-12 02:11:36 +08:00
* `--require-sha`: abort installation of cask if no checksum is defined.
* `--no-quarantine`: [disable Apples quarantining](https://docs.brew.sh/FAQ#why-cant-i-open-a-mac-app-from-an-unidentified-developer) for the specific app.
2023-09-12 02:11:36 +08:00
* `--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
2020-11-11 19:12:59 +08:00
You can also modify the default installation locations used when issuing `brew install`:
* `--appdir=/my/path` changes the path where the applications will be moved. Default is `/Applications`.
2023-09-12 02:11:36 +08:00
* `--fontdir=/my/path` changes the path for fonts. Default is `~/Library/Fonts`.
2014-01-28 23:17:50 +08:00
2020-11-11 19:12:59 +08:00
See `man brew` for the other default installation locations and the flags to change them.
To make these settings persistent, you might want to add the following line to your `.profile`, `.bash_profile` or `.zprofile`:
```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
2023-09-12 02:09:44 +08:00
# Will force the Google 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
2023-09-12 02:09:44 +08:00
brew install --appdir="/Applications" google-chrome
```
## Other Ways to Specify a Cask
2023-09-12 02:11:36 +08:00
Most `brew` commands can accept a cask token as an argument. As described above, the token on the command line can take the form of:
2020-11-11 19:12:59 +08:00
* A simple token, _e.g._: `google-chrome`.
2023-09-12 02:11:36 +08:00
* A fully-qualified token which includes the tap, _e.g._: `homebrew/cask/google-chrome`.
2020-11-11 19:12:59 +08:00
`brew` also accepts three other forms as arguments:
2023-09-12 02:11:36 +08:00
* A path to a cask file, _e.g._: `/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks/g/google-chrome.rb`.
* A `curl`-retrievable URI to a cask file, _e.g._: `https://raw.githubusercontent.com/Homebrew/homebrew-cask/HEAD/Casks/g/google-chrome.rb`.
* A file in the current working directory, _e.g._: `my-modified-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, _e.g._: `./google-chrome.rb`.
2023-09-12 02:11:36 +08:00
The last three forms are intended for users who wish to maintain private casks.
## Taps
2023-09-12 02:11:36 +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.