homebrew 安装步骤
首先挂🪜访问:https://brew.sh/zh-cn/
复制安装命令,安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
安装过程大概两分钟左右
mac@macdeMac-mini ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ==> Checking for `sudo` access (which may request your password)... Password: ==> This script will install: /opt/homebrew/bin/brew /opt/homebrew/share/doc/homebrew /opt/homebrew/share/man/man1/brew.1 /opt/homebrew/share/zsh/site-functions/_brew /opt/homebrew/etc/bash_completion.d/brew /opt/homebrew Press RETURN/ENTER to continue or any other key to abort: ==> /usr/bin/sudo /usr/sbin/chown -R mac:admin /opt/homebrew ==> Downloading and installing Homebrew... ==> Updating Homebrew... Updated 1 tap (homebrew/core). Warning: /opt/homebrew/bin is not in your PATH. Instructions on how to configure your shell for Homebrew can be found in the 'Next steps' section below. ==> Installation successful! ==> Homebrew has enabled anonymous aggregate formulae and cask analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics No analytics data has been sent yet (nor will any be during this install run). ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Next steps: - Run these commands in your terminal to add Homebrew to your PATH: echo >> /Users/mac/.zprofile echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/mac/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" - Run brew help to get started - Further documentation: https://docs.brew.sh
接下来,按照命令的输出命令配置环境环境变量
echo >> /Users/mac/.zprofile echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/mac/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
安装好后,可以配置镜像源
以中科大源为例:
地址:https://mirrors.ustc.edu.cn/
配置文档:https://mirrors.ustc.edu.cn/help/brew.git.html
# 替换 USTC 镜像 export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git" brew update
若用户设置了环境变量 HOMEBREW_BREW_GIT_REMOTE,则每次运行 brew update 时将会自动设置远程。推荐用户将环境变量 HOMEBREW_BREW_GIT_REMOTE 加入 shell 的 profile 设置中。
# 对于 bash 用户 echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.bash_profile# 对于 zsh 用户 echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.zshrc
用以下命令查看终端使用的是 Bash 还是 Zsh
echo $SHELL
重置为官方地址:
unset HOMEBREW_BREW_GIT_REMOTE git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew
本站文章除注明转载/出处外,均为原创,若要转载请务必注明出处。转载后请将转载链接通过邮件告知我站,谢谢合作。本站邮箱:admin@only4.work
尊重他人劳动成果,共创和谐网络环境。点击版权声明查看本站相关条款。