Last active
April 26, 2023 06:19
-
-
Save hufeng/f3903a251be92a0bfd04a95952b16b83 to your computer and use it in GitHub Desktop.
build a fast homebrew
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Let's configure a fast homebrew environment for you. 🚀" | |
# set homebrew environment variables | |
export HOMEBREW_INSTALL_FROM_API=1 | |
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api" | |
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" | |
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" | |
test -r ~/.bashrc && cat >>~/.bashrc <<EOF | |
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api" | |
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" | |
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" | |
EOF | |
test -r ~/.zshrc && cat >>~/.zshrc <<EOF | |
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api" | |
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" | |
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" | |
EOF | |
# install homebrew | |
curl -fsSL https://ghproxy.com/https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash | |
platform=$(uname -m) | |
os=$(uname -s) | |
# Apple Silicon CPU 设备上的 macOS 系统 | |
if [ "$platform" == "arm64" ]; then | |
test -r ~/.bashrc && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>~/.bashrc | |
test -r ~/.zshrc && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>~/.zshrc | |
fi | |
# 针对 Linux 系统上的 Linuxbrew: | |
if [ "$os" == "Linux" ]; then | |
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)" | |
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" | |
test -r ~/.bashrc && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bashrc | |
test -r ~/.zshrc&& echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.zshrc | |
fi | |
brew update | |
echo "Homebrew is ready to use. 🎉" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在linux上,不同发型版本有自己的包管理工具,如:
虽然使用方式上各异,但是大同小异,核心的问题在于软件的更新上,
一些版本为了追求稳定性,所以默认的软件仓库中的都比较老,
但是,对于开发状态来说 需要尝试新版本的特性
Mac上一般是用homebrew来进行软件的管理,使用体验非常优秀,软件更新非常及时,使用简单
能否统一Mac和Linux的软件管理体验,答案是ok,👍
homebrew支持linux和mac的平台,但是homebrew默认使用github作为软件源,国内访问比较慢
结合清华大学对于homebrew的镜像托管,起到了很好的速度提升。
此脚本自动化的实现 mac / linux 平台上的homebrew的安装和加速。