Skip to content

Instantly share code, notes, and snippets.

@ttchengcheng
Last active October 12, 2017 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttchengcheng/a279a548b0f9db6ffa5773299335ab34 to your computer and use it in GitHub Desktop.
Save ttchengcheng/a279a548b0f9db6ffa5773299335ab34 to your computer and use it in GitHub Desktop.
switch sources of Homebrew
# 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