Homebrew 简介
安装 Brew,网址(https://brew.sh/index_zh-cn.html)
¥ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Homebrew能够做什么?
使用 Homebrew 安装 Apple 没有预装但 你需要的东西 。Homebrew 使 macOS 更完整。使用gem
来安装 gems、用brew
来安装那些依赖包。
$ brew install wget
Homebrew 会将软件包安装到独立目录,并将其文件软链接至 /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
Homebrew 不会将文件安装到它本身目录之外,所以您可将 Homebrew 安装到任意位置。
轻松创建你自己的 Homebrew 包。
$ brew create https://foo.com/bar-1.0.tgz
Created /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/bar.rb
完全基于 git 和 ruby,所以自由修改的同时你仍可以轻松撤销你的变更或与上游更新合并。
$ brew edit wget # 使用 $EDITOR 编辑!
Homebrew 的配方都是简单的 Ruby 脚本:
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
更换 brew 源
# 1.
cd "$(brew --repo)"
# 查看配置
git remote -v
origin https://github.com/Homebrew/brew (fetch)
origin https://github.com/Homebrew/brew (push)
# 设置源
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 2.
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 查看配置
git remote -v
origin https://github.com/Homebrew/homebrew-core (fetch)
origin https://github.com/Homebrew/homebrew-core (push)
# 设置源
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git