HomeBrew

文档

  1. https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

前提条件

安装 Git

# Debian/Ubuntu
apt update
apt install -y git
# CentOS
yum install -y git

安装 curl

# Debian/Ubuntu
apt update
apt install -y curl
# CentOS
yum install -y curl

使用非 root 用户

# Debian/Ubuntu
# 添加用户:创建用户文件夹、指定 Shell
useradd -m -s /bin/bash xuxiaowei
# 修改密码
passwd xuxiaowei
# 添加 sudo 权限
sudo usermod -aG sudo xuxiaowei
# 切换用户
sudo su xuxiaowei
# 进入用户文件夹
cd ~
# CentOS
# 添加用户:创建用户文件夹、指定 Shell
useradd -m -s /bin/bash xuxiaowei
# 修改密码
passwd xuxiaowei
# 添加 sudo 权限
sudo usermod -aG wheel xuxiaowei
# 切换用户
sudo su xuxiaowei
# 进入用户文件夹
cd ~

安装

# 清华大学开源软件镜像站
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/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_INSTALL_FROM_API=1

git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
# GitHub
/bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install.sh)"

配置

  1. 只能使用 安装 HomeBrew 用户 安装/更新 软件
  2. 其他用户 运行下列配置后,可以使用 HomeBrew 已经安装好的软件
# Linux
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.bash_profile
test -r ~/.profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.profile
test -r ~/.zprofile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.zprofile
brew -v
# Apple Silicon CPU
test -r ~/.bash_profile && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>~/.bash_profile
test -r ~/.zprofile && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>~/.zprofile
brew -v

测试安装

# neovim
brew list
brew install neovim
nvim -v
nvim -V1 -v