8 Useful Examples of Using `brew --cask` Command (with examples)

Homebrew is a popular package manager for macOS that allows users to easily install and manage software packages from the command line. In addition to managing command-line tools and libraries, Homebrew also allows users to manage macOS applications distributed as binaries using the brew --cask command.

In this article, we will explore 8 different use cases of the brew --cask command with detailed explanations and code examples.

1. Searching for Formulas and Casks

To search for formulas and casks available in Homebrew, you can use the following command:

brew search text

Motivation: This command is useful when you want to find a specific package or application available in Homebrew.

Arguments:

  • text: The text to search for. It can be a package name, keywords, or any other relevant information.

Example:

brew search firefox

Output:

==> Casks
firefox

2. Installing a Cask

To install a cask from Homebrew, use the following command:

brew install --cask cask_name

Motivation: This command allows you to easily install macOS applications as binaries directly from the command line.

Arguments:

  • cask_name: The name of the cask to install.

Example:

brew install --cask firefox

Output:

==> Satisfying dependencies
==> Downloading https://downloads.mozilla.org/pub/mozilla.org/firefox/releases/...
==> Downloading from https://cdn-aws.deb.debian.org/firefox/releases/...
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'firefox'.
==> Installing Cask firefox
==> Linking Binary 'FirefoxDeveloperEdition.app' to '/Applications/FirefoxDeveloperEdition.app'.
🍺  firefox was successfully installed!

3. Listing All Installed Casks

To list all the installed casks, simply run the following command:

brew list --cask

Motivation: This command allows you to view a list of all the macOS applications that were installed using brew --cask.

Example:

brew list --cask

Output:

firefox

4. Listing Installed Casks with Newer Versions

To list installed casks that have newer versions available, use the following command:

brew outdated --cask

Motivation: This command helps you identify outdated macOS applications that can be updated to newer versions.

Example:

brew outdated --cask

Output:

firefox (latest: 88.0)

5. Upgrading an Installed Cask

To upgrade an installed cask, you can use the following command:

brew upgrade --cask cask_name

Motivation: This command allows you to easily update an installed macOS application to the latest available version.

Arguments:

  • cask_name: The name of the cask to upgrade. If not specified, all installed casks will be upgraded.

Example:

brew upgrade --cask firefox

Output:

==> Upgrading 1 outdated package:
firefox 87.0 -> 88.0
==> Upgrading Cask firefox
==> Downloading https://downloads.mozilla.org/pub/mozilla.org/firefox/releases/...
==> Downloading from https://cdn-aws.deb.debian.org/firefox/releases/...
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'firefox'.
==> Uninstalling Cask firefox
==> Unlinking Binary '/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/firefox'.
==> Unlinking Binary '/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/plugin-container.app/Contents/MacOS/plugin-container'.
==> Unlinking Binary '/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/updater'.  
==> Purging files for version 87.0 of Cask firefox
==> Installing Cask firefox
==> Linking Binary 'FirefoxDeveloperEdition.app' to '/Applications/FirefoxDeveloperEdition.app'.
🍺  firefox was successfully upgraded!

6. Uninstalling a Cask

To uninstall a cask, you can use the following command:

brew uninstall --cask cask_name

Motivation: This command allows you to remove an installed macOS application that was installed using brew --cask.

Arguments:

  • cask_name: The name of the cask to uninstall.

Example:

brew uninstall --cask firefox

Output:

==> Uninstalling Cask firefox
==> Unlinking Binary '/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/firefox'.
==> Unlinking Binary '/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/plugin-container.app/Contents/MacOS/plugin-container'.
==> Unlinking Binary '/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/updater'.  
==> Purging files for version 88.0 of Cask firefox
🍺  firefox was successfully uninstalled!

7. Uninstalling a Cask and Removing Settings and Files

To completely remove a cask and all related settings and files, use the following command:

brew zap --cask cask_name

Motivation: This command is useful when you want to perform a clean uninstallation of a macOS application installed with brew --cask, removing all associated files and configurations.

Arguments:

  • cask_name: The name of the cask to uninstall and zap.

Example:

brew zap --cask firefox

Output:

Uninstalling Cask firefox, removing all associated files...
(1/4) Removing: /usr/local/Caskroom/firefox
(2/4) Removing: /Users/your_username/Library/Application Support/firefox
(3/4) Removing: /Users/your_username/Library/Caches/firefox
(4/4) Removing: /Users/your_username/Library/Preferences/org.mozilla.firefox.plist
🍻  firefox was successfully uninstalled and zapped!

8. Displaying Information about a Cask

To view detailed information about a specific cask, you can use the following command:

brew info --cask cask_name

Motivation: This command can provide you with important information about a cask, including its version, description, dependencies, and more.

Arguments:

  • cask_name: The name of the cask to display information about.

Example:

brew info --cask firefox

Output:

firefox: 87.0 Caskroom
Mozilla Firefox Developer Edition is a version of Firefox tailored for developers...

In conclusion, the brew --cask command is a powerful tool for managing macOS applications as binaries. Whether you need to search for packages, install applications, update outdated versions, or uninstall and remove associated files, Homebrew’s brew --cask command provides a convenient workflow for administering macOS applications from the command line.

Related Posts

How to use the command 'crunch' (with examples)

How to use the command 'crunch' (with examples)

The ‘crunch’ command is a powerful wordlist generator. It can be used to create custom wordlists for various purposes such as password cracking, data analysis, or network security testing.

Read More
Using kpartx to Manage Partition Mappings (with examples)

Using kpartx to Manage Partition Mappings (with examples)

Add partition mappings: kpartx -a whole_disk.img Motivation: Adding partition mappings allows us to access individual partitions within a disk image file without the need for manual calculations or mounting the entire disk image.

Read More
How to use the command "machine" (with examples)

How to use the command "machine" (with examples)

The command “machine” is used to print the machine type. It provides information about the CPU architecture of the machine.

Read More