# brm **Repository Path**: philiam/brm ## Basic Information - **Project Name**: brm - **Description**: homebrew 源切换工具 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-05-02 - **Last Updated**: 2026-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # brm Homebrew 镜像源管理工具,像 nrm 切换 npm 源一样切换 Homebrew 源。 ## 安装 ```bash curl -fsSL https://gitee.com/philiam/brm/raw/main/install.sh | bash ``` ## 使用 ```bash brm ls # 列出所有可用源 brm use ustc # 切换到中科大镜像 brm info # 查看当前源的详细 URL brm info tuna # 查看指定源的详细 URL brm current # 查看当前源名称 ``` 切换后执行一次,使当前终端立即生效: ```bash source ~/.zshrc # zsh 用户 source ~/.bash_profile # bash 用户 ``` ## 可用源 | 名称 | 说明 | |------------|-------------------| | `official` | Homebrew 官方(GitHub) | | `ustc` | 中科大镜像 | | `tuna` | 清华镜像 | | `bfsu` | 北外镜像 | | `aliyun` | 阿里云镜像 | ## 原理 每次切换做三件事: 1. `git remote set-url` 更新 Homebrew 本地仓库的 remote URL 2. 在 shell 配置文件(`.zshrc` / `.bash_profile`)中写入 `HOMEBREW_BOTTLE_DOMAIN` 等环境变量 3. 记录当前源到 `~/.local/share/brm/current` 环境变量块用 marker 包裹,切换时自动替换,不会重复追加: ```bash # >>> brm managed >>> export HOMEBREW_BREW_GIT_REMOTE="..." export HOMEBREW_BOTTLE_DOMAIN="..." # <<< brm managed <<< ``` ## 要求 - macOS - Homebrew 已安装 - bash 3.2+ 或 zsh