Homebrew routine use tutorial

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:

  1. The directory contains spaces
  2. Do not install in /sw or /opt/local directory

Common commands

1. Install and uninstall the software

  1. brew --version or brew -v Display brew version information
  2. brew install Install the specified software
  3. brew unistall Uninstall the specified software
  4. brew list Show all installed software
  5. brew search text Search for software in local and remote warehouses, a green tick will be displayed if it is installed
  6. 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

  1. brew update Automatically upgrade homebrew (download the latest version from github)
  2. brew outdated Detect outdated software
  3. brew upgrade Upgrade all outdated software, that is, outdated software is listed
  4. brew upgrade Upgrade the specified software
  5. brew pin Prohibit the specified software upgrade
  6. brew unpin Unlock and prohibit upgrade
  7. 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

  1. brew cleanup -n List the contents that need to be cleaned up
  2. brew cleanup clean up the specified software outdated package
  3. brew cleanup clean up all outdated software
  4. brew unistall Uninstall the specified software
  5. brew unistall --force Completely uninstall the specified software, including the old version
  6. < /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 run
    gradle -v

Leave a Comment

Your email address will not be published.