Last active
October 12, 2017 03:27
-
-
Save ttchengcheng/a279a548b0f9db6ffa5773299335ab34 to your computer and use it in GitHub Desktop.
switch sources of Homebrew
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
# switch sources of Homebrew | |
_brewsrc() { | |
# save current working dir | |
pwd=$(PWD) | |
if [ "$1" = "0" ]; then | |
echo "restore brew source to default" | |
cd "$(brew --repo)" | |
git remote set-url origin https://github.com/Homebrew/brew.git | |
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" | |
git remote set-url origin https://github.com/Homebrew/homebrew-core.git | |
elif [ "$1" = "1" ]; then | |
echo "set brew source to tsinghua" | |
cd "$(brew --repo)" | |
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git | |
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" | |
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git | |
elif [ "$1" = "2" ]; then | |
echo "set brew source to ustc" | |
cd "$(brew --repo)" | |
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git | |
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" | |
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git | |
else | |
echo "" | |
echo " USAGE: _brewsrc [src]" | |
echo "" | |
echo " valid src are the following:" | |
echo "" | |
echo " 0 default" | |
echo " 1 mirrors.tuna.tsinghua.edu.cn" | |
echo " 2 mirrors.ustc.edu.cn" | |
echo "" | |
fi | |
# restore current working dir | |
cd $pwd | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment