安装homebrew

最近被MacBook的续航吸引,换了第一台MacBook——M2 的 MBA,安装Homebrew。

安装命令:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安装完成后以为没有成功:

[glm@GLMsMBAM2 ~ % brew -v
zsh: command not found: brew

网上查了下,安装完成后还需要使用两条命令配置brew的安装路径到环境变量:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

如下,成功了:

[glm@GLMsMBAM2 ~ % eval "$(/opt/homebrew/bin/brew shellenv)"
[glm@GLMsMBAM2 ~ % cat ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
[glm@GLMsMBAM2 ~ % brew -v
Homebrew 4.3.9

备注:参考了这篇文章

卸载Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"