Mac HomeBrew安装及镜像配置

安装

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

安装缓慢问题

  1. 替换homebrew.git
    1
    2
    cd $(brew --repo)
    git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
  2. 替换homebrew-core.git
    1
    2
    cd $(brew --repo)/Library/Taps/homebrew/homebrew-core
    git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
  3. 查看shell配置文件,根据配置文件修改步骤4|5
    1
    echo $SHELL
  4. /bin/zsh替换homebrew-bottles
    1
    2
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
    source ~/.zshrc
  5. /bin/bash替换homebrew-bottles
    1
    2
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
    source ~/.bash_profile

恢复默认配置

1
2
3
4
5
6
7
8
// step1:
cd $(brew --repo)
git remote set-url origin https://github.com/Homebrew/brew.git
// step2:
cd $(brew --repo)/Library/Taps/homebrew/homebrew-core
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
// step3:
// 将添加到~/.zshrc|~/.bash_profile文件的语句注释掉即可