Search software

The brew search [TEXT | / REGEX /] is used to search software, support the use of regular expressions for complex search.

For example, query the static blog generation tool Hugo:

$ brew search hugo

==> Searching local taps...
hugo ✔
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...
Copy the code

View the installed packages

View installed packages

brew list

View information about packages

Brew Info allows you to view information about packages, most useful for package dependencies and corresponding commands. Nginx will tell you how to add launchctl, and PostgreSQL will tell you how to migrate databases. This information is automatically displayed after the package is installed, and can be easily viewed with this command if you forget it.

brew info $FORMULA    Display information about a package
brew info             # display the number of packages installed, the number of files, and the total space occupiedBrew DEps displays package dependencies, which I often use to look at installed package dependencies and determine which packages are safe to remove. brew deps --installed --tree# View installed package dependencies, tree display
Copy the code

Update the Homebrew

To get a list of the latest packages, you first have to update Homebrew itself. This can be done with Brew Update.

After brew update, a list of packages that can be updated is displayed, with the checked packages already installed.

Update package (formula)

Before updating, I use Brew Outdated to see which packages can be updated.

Brew Outdated can then be updated with Brew Upgrade. Homebrew installs the new version of the package, but the old version remains

Brew Upgrade # Update all packages

Brew upgrade $FORMULA # Updates the specified package

Clean up the old version

The new version is installed and the old version is not needed. I use brew cleanup to cleanup old versions and cache files. Homebrew will only remove packages that are older than those currently installed, so don’t worry about packages that aren’t updated but have been deleted.

Brew cleanup # Clean old versions of all packages

Brew cleanup $FORMULA # Cleans up old versions of specified packages

Brew cleanup -n # View old cleanable packages without actual action

Now everything that needs to be updated has been updated and the old version has been cleaned up.

In Homebrew’s case, if all versions of a package are not uninstalled, Homebrew continues to try to install the latest version of the package. To uninstall a package completely, run the following command:

brew uninstall formula_name --force

Lock packages that do not want to be updated

Brew Update is very convenient to update all packages at once if updates are frequent. But we sometimes worry about automatic updates that update packages that we don’t want to update. Databases fall into this category, especially PostgreSQL updates that migrate databases across minor releases. We would prefer to deal with it alone at some time. Brew pin can be used to lock the package and Brew Update will skip it.

brew pin $FORMULA      Lock a package
brew unpin $FORMULA    # unlock
Copy the code

Service management

Brew services A piece of software used to easily manage brew installations, similar to the Linux service command.

brew services command:
Integrates Homebrew formulae with macOS' launchctl manager. [sudo] brew services list: List all running services for the current user (or root). [sudo] brew services run (formula|--all): Run the service formula without registering to launch at login (or boot). [sudo] brew services start (formula|--all): Start the service formula immediately and register it to launch at login (or boot). [sudo] brew services stop (formula|--all): Stop the service formula immediately and unregister it from launching at login (or boot). [sudo] brew services restart (formula|--all): Stop (if necessary) and start the service formula immediately and register it to launch at login (or boot). [sudo] brew services cleanup: Remove all unused services. If sudo is passed, operate on /Library/LaunchDaemons (started at boot). Otherwise, operate on ~/Library/LaunchAgents (started at login).Copy the code

Viewing Configuration Information

Brew Config Is used to view the BREW environment and related configurations

Diagnose the problem

Brew Doctor diagnoses current BREW problems and provides solutions

Warehouse management

Brew tap List of installed repositories brew tap [--full] user/repo [URL] Add repository brew untap tap Remove repositoryCopy the code

Replace the homebrew source

Replace the homebrew default source

cd "$(brew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
Copy the code

Replace the homebrew – the core source

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git
Copy the code

Homebrew visual management tools

If you don’t want to memorize so many commands, you can also use Cakebrew (official website) for visual management

You can run the following command to install it

brew cask install cakebrew
Copy the code

Then you can enjoy Homebrew

Visual management of Homebrew Services

LaunchRocket is a very user-friendly graphical interface that is easy and quick to use. For example, if you install Mysql, Redis, and MongoDB using Homebrew, do you want them to start automatically or manually? The traditional way is to use the command line command.

Installation method:

brew tap jimbojsb/launchrocket
brew cask install launchrocket
Copy the code

You can then launch it in the System Settings panel

The program interface is as follows

This article is also published in the wechat public number [Alley Information], welcome to scan the code to pay attention to!