安装 Homebrew#
打开终端#
Command⌘-空格 打开聚焦搜索, 搜索 终端 并打开.
安装 XCode#
输入 xcode-select --install
并 回车, 在弹出的页面中点击 , 再点击 , 等待安装完成.

安装 xcode-select#
设置 Homebrew/Linuxbrew 安装镜像#
在终端输入以下命令设置安装镜像:
提示
对于以下执行的命令块, 你应该依次执行, 对每个命令进行如下操作:
- 复制命令
通过
来复制命令.- 粘贴命令到终端中
在窗口内 右键 然后选择
.请勿使用 Control-V 进行粘贴! 如果习惯性按了, 请狂按几次 删除键.
- 执行命令
通过在窗口内 回车 执行命令, 当终端再次出现 终端刚打开时的窗口样式 时, 命令执行完毕.
如果命令停住不继续执行, 可能是因为这个命令需要你进行再次确认; 对于本教程而言, 狂敲几次 回车 即可.
如果实在卡住太长时间, 你可以 Ctrl-C 终止执行, 然后重新输入并执行命令.
- 确认完成命令
当终端再次出现 终端刚打开时的窗口样式 时, 命令执行完毕. 这时, 你可以执行下一条命令.
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
安装 Homebrew/Linuxbrew#
在终端运行以下命令以安装 Homebrew/Linuxbrew.
/bin/bash -c "$(curl -fsSL https://mirrors.ustc.edu.cn/misc/brew-install.sh)"
设置 Homebrew/Linuxbrew 环境变量#
输入 uname -m
并 回车, 如果输出 arm64
则需要添加环境变量, 否则跳过这一部分.
将 brew 程序的相关路径加入到环境变量中.
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bashrc
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.profile
eval "$(/opt/homebrew/bin/brew shellenv)"
配置下载镜像源#
备注
如果按照 设置 Homebrew/Linuxbrew 环境变量 备注中的 Next steps 操作了, 跳过这一步.
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.bashrc
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.bashrc
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.bashrc
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.bashrc
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.bash_profile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.bash_profile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.bash_profile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.zshrc
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.zshrc
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.zshrc
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.zshrc
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.zprofile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.zprofile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.zprofile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.zprofile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.profile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.profile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.profile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.profile
设置 Homebrew 自动更新软件#
警告
此部分在安装时需要确保网络可访问 github, 不行请跳过.
brew tap homebrew/autoupdate
安装好后, 使用 brew autoupdate --help
可查看命令说明, 以下是我使用的:
brew install pinentry-mac
mkdir -p /Users/feignclaims/Library/LaunchAgents
brew autoupdate start --upgrade --greedy --cleanup --sudo