官方渠道安装

HomeBrew的官网链接:https://brew.sh/index_zh-cn

可以看到,官网给出了一条安装脚本,可以直接在终端执行。但是,可能会出现无法访问或速度极慢的情况,所以还是极力推荐使用下面的国内脚本安装。

官方脚本:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

 

国内脚本安装

这里要感谢CunKai的Gitee项目:https://gitee.com/cunkai/HomebrewCN/

同样,他也给出了可以直接执行的安装脚本

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

 

终端执行命令后,可以看到都是中文,根据他的提示,这里输入1(中科大下载源)或者2(清华大学下载源)比较好。

按照命令一步步执行然后等待下载完成即可。

更换国内下载源:

brew中软件不是所有都是托管的,只有国内镜像源缓存的才能国内下载。

中科大源:

# 替换brew.git:
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 替换homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# 替换homebrew-bottles:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 应用生效:
$ brew update

 

清华源:

# 替换brew.git:
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 替换homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# 替换homebrew-bottles:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 应用生效:
$ brew update

 

posted on 2020-12-09 10:49  FuYingju  阅读(418)  评论(0编辑  收藏  举报