由于国内大长城的存在导致国外一些好的工具或者资源不是被墙就是访问速度奇慢。对于Homebrew也是如此。如果使用官方给出的安装办法安装homebrew则是非常的简洁,对于网络"给力"的同学请直接使用官方所给出的方法进行安装即可,下面给出友情连接
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
如果在terminal中输入以上命令提示任何失败的时候,请继续往下看。
homebrew本身也是使用git进行管理并且托管于github中的,还好国内的TUNA和gitee都有其镜像,这里我推荐使用TUNA的源,因为homebrew的全套他都有而且同步也比较及时,起码对于我来说够用了。TUNA链接如下
https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
其给出的上游链接如下
#homebrew
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
#homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
#homebrew-cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
下面给出配置步骤
1. 根据TUNA给出的镜像地址,下载homebrew
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git --depth=1
下载完成后,在当前目录下则会出现brew文件夹。
2.建立文件夹 Library/Taps/homebrew/
mkdir -p ./brew/Library/Taps/homebrew/
3.根据TUNA给的镜像地址,下载homebrew-core及homebrew-cask
cd ./brew/Library/Taps/homebrew/
#homebrew-core
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git --depth=1
#homebrew-cask
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git --depth=1
待下载ok后,目录./brew/Library/Taps/homebrew/的结构如下
$ ls
homebrew-cask homebrew-core
4.移动目录brew到/usr/local/下,并更名为Homebrew
$mv brew /usr/local/Homebrew
5.在目录/usr/local/bin/下做一例brew的软连接,方便全局访问brew
$ln -s /usr/local/Homebrew/bin/brew /usr/local/bin/brew
6.更新brew
$brew update
7.接下来就可以进行软件的安装了
$brew install tree