From 3289d846adfd899f612242b5afd0fb450c24863d Mon Sep 17 00:00:00 2001 From: Luk Date: Tue, 21 May 2024 21:14:39 +0800 Subject: [PATCH] u --- mac-homebrew-china.sh | 36 ++++++++++++++++++++++++------------ mac-homebrew-install.sh | 6 +++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/mac-homebrew-china.sh b/mac-homebrew-china.sh index 6ad1040..594d54c 100644 --- a/mac-homebrew-china.sh +++ b/mac-homebrew-china.sh @@ -1,19 +1,31 @@ -echo === Enter [g] to reset git source to github, [c] to mirrors in china +echo === Enter [g] to reset git source to github, [a] to 阿里云, [z] to 中科大, [q] to 清华, [anything else] to quit: read -p '>>> ' TARGET -if [ "$TARGET"='g' ] +if [ "$TARGET" = 'g' ] then - git -C /usr/local/Homebrew remote set-url origin https://github.com/Homebrew/brew.git - git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core remote set-url origin https://github.com/Homebrew/homebrew-core.git - git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask remote set-url origin https://github.com/Homebrew/homebrew-cask -elif [ "$TARGET"='c' ] + git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git + git -C "$(brew --repo homebrew-core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git + git -C "$(brew --repo homebrew-cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask +elif [ "$TARGET" = 'z' ] then - git -C /usr/local/Homebrew remote set-url origin https://mirrors.ustc.edu.cn/brew.git - # 或 https://mirrors.aliyun.com/homebrew/brew.git - git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git - # 或 https://mirrors.aliyun.com/homebrew/homebrew-core.git - git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git + git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git + git -C "$(brew --repo homebrew-core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git + git -C "$(brew --repo homebrew-cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git + export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles +elif [ "$TARGET" = 'q' ] +then + git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git + git -C "$(brew --repo homebrew-core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git + git -C "$(brew --repo homebrew-cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles +elif [ "$TARGET" = 'a' ] +then + git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git + git -C "$(brew --repo homebrew-core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git + git -C "$(brew --repo homebrew-cask)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git + export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles +else + exit 0 fi -# https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/ +brew update diff --git a/mac-homebrew-install.sh b/mac-homebrew-install.sh index 5e0e226..81943c6 100644 --- a/mac-homebrew-install.sh +++ b/mac-homebrew-install.sh @@ -3,10 +3,11 @@ echo "Installing Homebrew on MacOS" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # default brew path: /opt/homebrew for Apple Silicon, /usr/local/Homebrew for macOS Intel and /home/linuxbrew/.linuxbrew for Linux -# add brew to path: + +# add brew to path on Apple Silicon: # (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/luk/.bash_profile # eval "$(/opt/homebrew/bin/brew shellenv)" -# +# 实际上执行了: # export HOMEBREW_PREFIX="/opt/homebrew"; # export HOMEBREW_CELLAR="/opt/homebrew/Cellar"; # export HOMEBREW_REPOSITORY="/opt/homebrew"; @@ -15,7 +16,6 @@ echo "Installing Homebrew on MacOS" # export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}"; # - # uninstall: https://github.com/homebrew/install#uninstall-homebrew # /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" # install emacs: brew cask install emacs