2 min read

homebrew

安装使用

  • 安装
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
注:期间会阻断,需要敲回车键继续,然后输入密码安装
  • 国内镜像源-中科大
# 替换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' >> ~/.zshrc
  • 国内镜像源-阿里云
# 替换brew.git:
cd "$(brew --repo)" && git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git 
# 替换homebrew-bottles
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_custom
  • 重置镜像源
# 重置brew.git:
cd "$(brew --repo)" && git remote set-url origin https://github.com/Homebrew/brew.git
# 重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://github.com/Homebrew/homebrew-core.git

cd $home && brew update
  • 使用
brew install [软件包],如:brew install wget

下载缓慢,手动下载

  • brew [cask] install <软件名>
    自动生成缓存文件,获取下载链接,例:


下载链接:https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10.2/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.pkg

手动下载文件,拷贝到缓存位置

  • ll ~/Library/Caches/Homebrew/downloads
  • 覆盖原来的缓存文件名
    例:cp ~/Downloads/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.pkg 436348d9da26743e0ad4ac73a028385399e9f02ae915743dae53ca104bbe790e--OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.pkg.incomplete
  • brew [cask] install <软件名>