homebrew is a package management tool under osx, which can easily manage all kinds of packages. The official definition is
macOS missing package manager
installation
1. Automatic installation (recommended)
execute The following command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The above command line is two commands, first download the install file, and then install it with the system’s ruby tool.
Try to install it under bash or zsh. Fish will prompt that’$’ is not recognized.
No need to use super authority (sudo), this file will install HomeBrew to the usr/local
directory. During the installation process, you will be prompted what actions Shuyuao will perform.
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
There will be some hints. If you continue, you will be prompted to enter the password and wait for the installation to complete.
After the installation is complete, enter brew -v
to show whether the installation is successful:
Homebrew 1.4.3
Homebrew/homebrew-core (git revision dba402; last commit 2018-01-09)
2. Manual installation
Execute the following command:
mkdir homebrew && curl -L https:// github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Avoid the following two points:
- The directory contains spaces
- Do not install in
/sw
or/opt/local
directory
Common commands
1. Install and uninstall the software
-
brew --version
orbrew -v
Display brew version information -
brew install
Install the specified software -
brew unistall
Uninstall the specified software -
brew list
Show all installed software -
brew search text
Search for software in local and remote warehouses, a green tick will be displayed if it is installed -
brew search /text/
Use regular expressions to search for software
For example: enter directly
brew search gradle
The following content is displayed :
~/ brew search gradle
==> Searching local taps...
gradle ✔ gradle-completi on [email protected]
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...
Enter a regular expression
brew search /gra\wle/
The following content is displayed:
~/ brew search /gra\wle/
==> Searching local taps...
gradle ✔ gradle-completion [email protected]
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...
2. Software upgrade related
-
brew update
Automatically upgrade homebrew (download the latest version from github) -
brew outdated
Detect outdated software -
brew upgrade
Upgrade all outdated software, that is, outdated software is listed -
brew upgrade
Upgrade the specified software -
brew pin
Prohibit the specified software upgrade -
brew unpin
Unlock and prohibit upgrade -
brew upgrade --all
Upgrade all packages, including uncleaned old packages
< h4>3. Cleanup related
homebrew upgrade The old version of the software will not be cleaned up. After the software is upgraded, we can use the following command to clean up
-
brew cleanup -n
List the contents that need to be cleaned up -
brew cleanup
clean up the specified software outdated package -
brew cleanup
clean up all outdated software -
brew unistall
Uninstall the specified software -
brew unistall
Completely uninstall the specified software, including the old version--force
< /ol>
The files installed by brew will automatically set environment variables, so don't worry about the problem that the command line cannot be started.
For example, after installing gradle, you can rungradle -v