安装
使用Homebrew 国内源安装脚本,贼方便:
            
            
              bash
              
              
            
          
          /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
        
切换至清华大学镜像源:
命令合并: 分别切换了 brew.git、 homebrew-core.git、 homebrew-bottles的git地址:
            
            
              bash
              
              
            
          
          git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
        命令分开:
- 
切换
brew.gitbashgit -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git - 
切换
homebrew-core.gitbashgit -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git - 
切换
homebrew-bottles使用的是 zsh 而非 bash shell
bashecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc使用的是 bash shell 而非 zsh时:
bashecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile - 
切换
homebrew-bottles/api使用 bash shell
bashecho 'export HOMEBREW_API_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api' >> ~/.bash_profile source ~/.bash_profile 
切换至中科大镜像源:
命令合并: 分别切换了 brew.git、 homebrew-core.git、 homebrew-bottles的git地址:
            
            
              bash
              
              
            
          
          git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
        命令分开:
- 
切换
brew.gitbashgit -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git - 
切换
homebrew-core.gitbashgit -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git - 
切换
homebrew-bottles使用的是 zsh 而非 bash shell
bashecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc使用的是 bash shell 而非 zsh时:
bashecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile - 
切换
homebrew-bottles/api使用 bash shell
bashecho 'export HOMEBREW_API_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/api' >> ~/.bash_profile source ~/.bash_profile 
完成以上操作后,你的Homebrew就会开始使用选定的镜像源。注意,如果你使用的是 bash shell 而非 zsh ,你需要将上述命令中的 .zshrc 替换为 .bash_profile 或 .bashrc。
你可以在终端中运行以下命令来查看你的默认登录 Shell:
bashecho $SHELL如果输出是 /bin/bash,那么你使用的是 Bash。如果输出是 /bin/zsh 或类似路径,那么你使用的是 Zsh。
最后,建议在切换镜像源后运行一次brew update以确保一切正常。
切换回Homebrew源:
- 
切换
brew.gitbashgit -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew - 
切换
homebrew-core.gitbashgit -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core