【 Homebrew series 】

  1. HomeBrew regular use tutorial
  2. Homebrew进阶使用教程(一)
  3. Homebrew Advanced Tutorial 2 – Build your own repository with a command line weather client
  4. Install and connect to Homebrew on MAC

I lot address: making address: https://github.com/rangaofei/homebrew-saka

Homebrew is a package management tool under OSX, which makes it easy to manage various packages. The official definition is

MacOS missing package manager

The installation

1. Automatic installation (recommended)

Run the following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy the code

The above command line is two commands, first download install file, and then use the system’s Ruby tool to install.

Try to install under bash or ZSH, fish will prompt that ‘$’ is not recognized.

You do not need to use super permission (sudo), this file will install HomeBrew to usr/local directory. During installation you will be prompted to tell you what actions to 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
Copy the code

There will be some hints later. If you continue, you will be prompted for a password and wait for the installation to complete.

After the installation is complete, enter BREW -V to display whether the installation is successful:

Homebrew/ Homebrew-core (Git Revision Dba402; last commit 2018-01-09)Copy the code

2. Install the server manually

Run the following command:

mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Copy the code

Avoid the following two:

  1. The directory contains Spaces
  2. Do not install/swor/opt/localdirectory

Alternatively, you can manually download the installation script and change the value of the HOMEBREW_PREFIX variable to your own installation directory.

Common commands

1. Install and uninstall software

  1. brew --versionorbrew -vThe BREW version is displayed
  2. brew install <formula>Install specified Software
  3. brew unistall <formulaUninstalling specified Software
  4. brew listDisplays all installed software
  5. brew search textSearch for local remote repository software, installed will show a green tick
  6. brew search /text/Use regular expression search software

One example: direct input

brew search gradle
Copy the code

The following information is displayed:

 ~/ brew search gradle
==> Searching localtaps... Gradle gradle- Completion [email protected] ==> Searching taps on bookmark... ==> Searching blacklisted, migrated and deleted formulae...Copy the code

Enter as a regular expression

brew search /gra\\wle/
Copy the code

The following information is displayed:

 ~/ brew search /gra\\wle/
==> Searching localtaps... Gradle gradle- Completion [email protected] ==> Searching taps on bookmark... ==> Searching blacklisted, migrated and deleted formulae...Copy the code

2. Upgrade the software

  1. brew updateAutomatically upgrade Homebrew (download the latest version from Github)
  2. brew outdatedCheck outdated software
  3. brew upgradeUpgrade all obsolete software, that is, listed as obsolete software
  4. brew upgrade <formula>Upgrade the specified software
  5. brew pin <formula>Do not upgrade specified software
  6. brew unpin <formula>Unlock forbid upgrade
  7. brew upgrade --allUpgrade all software packages, including uncleaned packages of older versions

3. Clean up

Homebrew does not clean up the old version when upgrading the software, we can use the following command to clean up after the software upgrade

  1. brew cleanup -nList what needs to be cleaned up
  2. brew cleanup <formula>Clean the specified software outdated packages
  3. brew cleanupClean up any outdated software
  4. brew unistall <formula>Uninstalling specified Software
  5. brew unistall <fromula> --forceComplete uninstallation of specified software, including older versions

Files installed over BREW have environment variables automatically set, so don’t worry about the command line not starting. For example, once gradle is installed, you can run Gradle -v