切换各种源

我们在使用一些工具的时候因为他们的服务或者资源托管在国外的服务器上,会导致我们请求或者下载的速度非常慢,这是一种非常不好的体验,切换相关镜像源使用国内的服务可以极大改善这种情况。

Homebrew

替换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

重置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

Ruby

gem

//查看源
gem sources -l

//添加源
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

//移除源
gem sources --remove https://rubygems.org/

Node

nvm

//切换源-临时设置源
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
nvm install node

//切换源-将源作为参数传递进去
NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node nvm install 4.2

//切换源-将源变量添加到bash当中(zsh同理)
echo -e "\nexport NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node" >> ~/.bashrc
source ~/.bashrc

npm

//查看源
npm config -g get registry

//切换源
npm config -g set registry https://registry.npm.taobao.org

Linux

Ubuntu下载镜像
http://mirrors.aliyun.com/ubuntu-releases/

其他OS镜像,可自行查阅阿里云官方镜像站
https://developer.aliyun.com/mirror/

镜像站

阿里云官方镜像站
https://developer.aliyun.com/mirror/