Last active
February 27, 2022 18:19
-
-
Save liby/3d5091bb811b2d3f537bf64b6fc2b19f to your computer and use it in GitHub Desktop.
Switch Homebrew to USTC Mirror
This file contains 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
git clone --bare [email protected]:liby/dotfiles.git $HOME/.cfg | |
function config { | |
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@ | |
} | |
mkdir -p .config-backup | |
config checkout | |
if [ $? = 0 ]; then | |
echo "Checked out config."; | |
else | |
echo "Backing up pre-existing dot files."; | |
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{} | |
fi; | |
config checkout | |
config config status.showUntrackedFiles no |
This file contains 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
#!/bin/sh | |
# 替换 brew.git | |
cd "$(brew --repo)" | |
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git | |
# 替换 homebrew-core.git | |
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" | |
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git | |
# 替换 homebrew-cask.git | |
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" | |
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git | |
# 更新 Homebrew 自身,促使上面的更改生效 | |
brew update | |
# 替换 homebrew-bottles | |
echo -e '\nexport HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc | |
# 重载加载 zsh | |
exec zsh |
This file contains 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
#!/bin/sh | |
# 替换 brew.git | |
cd "$(brew --repo)" | |
git remote set-url origin https://github.com/Homebrew/brew.git | |
# 替换 homebrew-core.git | |
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" | |
git remote set-url origin https://github.com/Homebrew/homebrew-core.git | |
# 替换 homebrew-cask.git | |
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" | |
git remote set-url origin https://github.com/Homebrew/homebrew-cask.git | |
# 更新 Homebrew 自身,促使上面的更改生效 | |
brew update | |
# 删除环境变量 HOMEBREW_BOTTLE_DOMAIN | |
sed -ie '/HOMEBREW_BOTTLE_DOMAIN/d' ~/.zshrc | |
# 重载加载 zsh | |
exec zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment