陈斌彬的技术博客

Stay foolish,stay hungry

Homebrew 简介

What Does Homebrew Do?

1.Homebrew installs the stuff you need that Apple didn’t.

$ brew install wget

2.Homebrew installs packages to their own directory and then symlinks their files into /usr/local.

$ cd /usr/local
$ find Cellar
Cellar/wget/1.16.1
Cellar/wget/1.16.1/bin/wget
Cellar/wget/1.16.1/share/man/man1/wget.1

$ ls -l bin
bin/wget -> ../Cellar/wget/1.16.1/bin/wget

3.Homebrew won’t install files outside its prefix, and you can place a Homebrew installation wherever you like.

4.Trivially create your own Homebrew packages.

$ brew create https://foo.com/bar-1.0.tgz
Created /usr/local/Library/Formula/bar.rb

5.It’s all git and ruby underneath, so hack away with the knowledge that you can easily revert your modifications and merge upstream updates.

$ brew edit wget # opens in $EDITOR!

6.Homebrew formulae are simple Ruby scripts:

class Wget < Formula
  homepage "https://www.gnu.org/software/wget/"
  url "https://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz"
  sha256 "52126be8cf1bddd7536886e74c053ad7d0ed2aa89b4b630f76785bac21695fcd"

  def install
    system "./configure", "--prefix=#{prefix}"
    system "make", "install"
  end
end

7.Homebrew complements OS X. Install your gems with gem, and their dependencies with brew. Homebrew

Command:

brew list                 # 查看已经安装的包
brew update               # 更新Homebrew自身
brew doctor               # 诊断关于Homebrew的问题(Homebrew 有问题时请用它)
brew cleanup              # 清理老版本软件包或者无用的文件
brew show                 # 查看包信息
brew search               # 按名称搜索
brew upgrade              # 升级软件包
brew install              # 按名称安装
brew uninstall            # 按名称卸载
brew pin/unpin            # 锁定或者解锁软件包版本,防止误升级
brew home                 # 用浏览器打开brew的官方网站
brew info                 # 显示软件信息
brew deps                 # 显示包依赖
brew uninstall []         # 卸载

Further Documentation

https://git.io/brew-docs