brew 是mac上常用的软件安装软件,但是由于众所周知周知的原因,国内访问外部软件库源速度很慢,所以需要设置国内的镜像软件源以加快软件安装速度。
这里我选择的清华大学的源:
# 替换brew源 cd "$(brew --repo)" # 默认:https://github.com/Homebrew/brew.git git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git # 替换homebrew-core.git cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" # 默认:https://github.com/Homebrew/homebrew-core.git git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git brew update
关闭brew自动更新,这样可以防止每次安装软件前的更新软件的耗时,我这里使用的zsh命令行工具,所以编辑的是
~/.zshrc
文件,在该文件最后一行增加export HOMEBREW_NO_AUTO_UPDATE=true
,然后执行source ~/.zshrc
命令。