brew安装及替换源

brew安装

常规官网安装

https://brew.sh

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

国内安装

解决安装太慢,或者无法安装(国内有时无法访问raw.githubusercontent.com)

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"

/bin/bash -c "$(curl -fsSL https://mirrors.ustc.edu.cn/misc/brew-install.sh)"

更换为国内源

https://mirrors.ustc.edu.cn/help/brew.git.html#homebrew-linuxbrew

# brew tap --custom-remote --force-auto-update homebrew/cask https://mirrors.ustc.edu.cn/homebrew-cask.git
brew tap --custom-remote --force-auto-update homebrew/cask-versions https://mirrors.ustc.edu.cn/homebrew-cask-versions.git
brew tap --custom-remote --force-auto-update homebrew/services https://mirrors.ustc.edu.cn/homebrew-services.git

brew tap --custom-remote --force-auto-update homebrew/cask-fonts https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
brew tap --custom-remote --force-auto-update homebrew/command-not-found https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-command-not-found.git

brew update -v

brew安装指定版本的软件

# 查看信息
brew info jmeter
# 根据信息中的From
cd "$(brew --repo)"
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
# 找到对应commitid
git log ./Formula/jmeter.rb | less
# 切换对应版本的commitid
git checkout d1c22f955a754d670e5ebe69eb4d970ed4429aeb
# 查看是否切换到对应版本
cat ./Formula/jmeter.rb
# 安装
brew install ./Formula/jmeter.rb
or
brew install jmeter

参考网站:

https://mirrors.ustc.edu.cn/help/brew.git.html#homebrew-linuxbrew

https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

https://www.jianshu.com/p/aadb54eac0a8