前言
Homebrew是什么?
Homebrew是“MacOS缺失的软件包管理器”,用来安装Mac没有预装但你需要的东西。
安装
官网安装法
进入官网,安装步骤介绍的很详细:
安装命令
打开终端,粘贴以下命令:
1
| /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
脚本会在执行前暂停,并说明将它将做什么。高级安装选项在 这里(required for OS X 10.8 Mountain Lion and below)。
Homebrew 会将软件包安装到独立目录,并将其文件软链接至 /usr/local 。
检查是否有冲突
安装完成后,检查是否有冲突
卸载Homebrew
1
| /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
|
换国内源安装
考虑到官网安装方法太慢,于是我们采用第二种方法
获取brew_install文件
1
| curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
|
编辑brew_install文件
1 2
| BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
|
安装brew
1
| /usr/bin/ruby ./brew_install
|
出现下面代码直接关闭终端
1 2
| ==> Tapping homebrew/core Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
|
执行下面这句命令,更换为中科院的镜像:
1
| git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
|
此刻就已经下载成功了
替换源
1 2 3 4 5 6 7
| cd "$(brew --repo)" git remote set-url origin git://mirrors.ustc.edu.cn/brew.git cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-cask.git
|
brew 更新
替换bintray镜像
1 2
| echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile
|