【MacBook系统homebrew镜像记录】

安装

使用Homebrew 国内源安装脚本,贼方便:

bash 复制代码
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

切换至清华大学镜像源:

命令合并: 分别切换了 brew.githomebrew-core.githomebrew-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

命令分开:

  1. 切换 brew.git

    bash 复制代码
    git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
  2. 切换 homebrew-core.git

    bash 复制代码
    git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
  3. 切换 homebrew-bottles

    使用的是 zsh 而非 bash shell

    bash 复制代码
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
    source ~/.zshrc

    使用的是 bash shell 而非 zsh时:

    bash 复制代码
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
    source ~/.bash_profile
  4. 切换 homebrew-bottles/api

    使用 bash shell

    bash 复制代码
    echo 'export HOMEBREW_API_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api' >> ~/.bash_profile
    source ~/.bash_profile

切换至中科大镜像源:

命令合并: 分别切换了 brew.githomebrew-core.githomebrew-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

命令分开:

  1. 切换 brew.git

    bash 复制代码
    git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
  2. 切换 homebrew-core.git

    bash 复制代码
    git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
  3. 切换 homebrew-bottles

    使用的是 zsh 而非 bash shell

    bash 复制代码
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
    source ~/.zshrc

    使用的是 bash shell 而非 zsh时:

    bash 复制代码
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
    source ~/.bash_profile
  4. 切换 homebrew-bottles/api

    使用 bash shell

    bash 复制代码
    echo '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:

bash 复制代码
echo $SHELL

如果输出是 /bin/bash,那么你使用的是 Bash。如果输出是 /bin/zsh 或类似路径,那么你使用的是 Zsh。

最后,建议在切换镜像源后运行一次brew update以确保一切正常。


切换回Homebrew源:

  1. 切换 brew.git

    bash 复制代码
    git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew
  2. 切换 homebrew-core.git

    bash 复制代码
    git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core
相关推荐
Wario1 天前
我在 Mac 上装了 Aerospace,效率翻倍不是说说而已
macos·mac
奕天者9 天前
计算机网络学习(八)——MAC
学习·计算机网络·mac
猫头虎11 天前
MacBookPro上macOS安装第三方应用报错解决方案:遇到:“无法打开“XXX”,因为无法确定(验证)开发者身份?怎么解决
macos·mac·策略模式·安全架构·mac安装软件·mac book·mac卸载软件
gadiaola13 天前
【苍穹外卖】Day01—Mac前端环境搭建
前端·nginx·macos·homebrew
猫头虎13 天前
MacBookPro上macOS安装第三方应用报错解决方案:遇到:“无法打开“XXX”,因为Apple无法检查其是否包含恶意软件 问题如何解决
macos·开源软件·mac·策略模式·远程工作·软件需求·安全架构
一如既往yes13 天前
Mac如何允许安装任何来源软件?
mac
拿回忆下酒15 天前
Electron+vite+vue3 从0到1搭建项目,开发Win、Mac客户端
windows·electron·mac·客户端·桌面客户端
羑悻的小杀马特16 天前
iOS:重新定义移动交互,引领智能生活新潮流
macos·ios·objective-c·cocoa·mac
私人珍藏库16 天前
[Mac] 开发环境部署工具ServBay 1.12.2
mac
闲人一小枚17 天前
mac 10.15.7 svn安装
svn·mac