首先,需要确保系统中安装了 bash、git 和 curl,对于 macOS 用户需额外要求安装 Command Line Tools (CLT) for Xcode。
对于 macOS 用户,系统自带 bash、git 和 curl,在命令行输入 xcode-select --install 安装 CLT for Xcode 即可。
对于 Linux 用户,系统自带 bash,仅需额外安装 git 和 curl。
接着,在终端输入以下几行命令设置环境变量:
if [[ “ ( u n a m e − s ) " = = " L i n u x " ] ] ; t h e n B R E W T Y P E = " l i n u x b r e w " ; e l s e B R E W T Y P E = " h o m e b r e w " ; f i e x p o r t H O M E B R E W B R E W G I T R E M O T E = " h t t p s : / / m i r r o r s . t u n a . t s i n g h u a . e d u . c n / g i t / h o m e b r e w / b r e w . g i t " e x p o r t H O M E B R E W C O R E G I T R E M O T E = " h t t p s : / / m i r r o r s . t u n a . t s i n g h u a . e d u . c n / g i t / h o m e b r e w / (uname -s)" == "Linux" ]]; then BREW_TYPE="linuxbrew"; else BREW_TYPE="homebrew"; fi export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/ (uname−s)"=="Linux"]];thenBREWTYPE="linuxbrew";elseBR