【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
相关推荐
吞掉星星的鲸鱼7 天前
MAC M1 安装brew 配置环境变量,安装dart
macos·终端·dart·brew
苏佰侨。8 天前
docker minio启动命令
linux·运维·windows·macos·docker·容器·mac
tekin9 天前
macos pyenv 安装python tk 、tkinter图形库方法步骤和使用总结
macos·tkinter·brew·pyenv·tcl-tk·tk图形库安装
sysin.org9 天前
在不受支持的 Mac 上安装 macOS Sequoia (OpenCore Legacy Patcher v2.0.1)
macos·mac·macbook pro·sequoia
中草药z10 天前
【JavaEE】数据链路层协议和DNS
网络·学习·mac·ip·dns·mtu·数据链路
姚杰献11 天前
MacOS上安装MiniConda的详细步骤
人工智能·python·深度学习·macos·机器学习·conda·mac
秦伟杰11 天前
mac M1,M2,M3芯片踩坑 nodejs ruby brew
arm·nodejs·ruby·mac·nvm·m2·brew·m1·rvm·m3·苹果芯片
AUV110711 天前
Mac剪贴板历史全记录!
macos·swiftui·mac·效率工具·实用工具·剪贴板·clipboard
一笑11 天前
在MAC中Ollama开放其他电脑访问
mac·ollama·ollama api·ollama外网访问
AUV110711 天前
Mac 上哪个剪切板增强工具比较好用? 好用剪切板工具推荐
macos·swiftui·mac·剪贴板·clipboard·剪贴板增强·app 推荐