git, npm, package control 配置镜像、代理那些事

在一家网络各类限制的公司呆久了,你会比其余人多几项技能,那就是会配置各类代理。来吧,一个一个的来。git

git

设置代理:github

git config --global http.proxy proxy-url:proxy-port

npm

配置镜像

  • 命令行全局设置npm

npm config set registry http://registry.cnpmjs.org
npm info underscore (若是上面配置正确这个命令会有字符串response)
  • 命令行指定网络

npm install xxx --registry http://registry.cnpmjs.org
  • 编辑 ~/.npmrc,添加以下内容网站

registry = http://registry.cnpmjs.org

设置代理

npm config set proxy http://server:port
npm config set https-proxy http://server:port

如需认证,使用以下命令:ui

npm config set proxy http://username:password@server:port
npm confit set https-proxy http://username:password@server:port

若是代理不支持https的话须要修改npm存放package的网站地址:this

npm config set registry "http://registry.npmjs.org/"

使用nrm管理切换npm源

nrm 是一个 NPM 源管理器,容许你快速地在以下 NPM 源间切换。详细url

Package Control

安装package control

首先找到package control的安装命令,再把代理信息加到安装命令上,以下命令中,将'proxy-url:proxy-port'替换成你的代理地址便可。spa

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler({'http':'proxy-url:proxy-port'}))); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')

使用package control安装插件

安装好package control后,若是要使用package control来安装插件,还须要设置package control。.net

在sublime text中找到配置文件,位置以下:

Preferences => Package Settings => Package Control => Settings-User

在 Package Control.sublime-settings--User 文件中,添加以下配置(proxy-url:proxy-port为你要设置的代理地址,如需帐号登陆,填写对应的username和password)便可:

{
    // An HTTP proxy server to use for requests. Not normally used on Windows
    // since the system proxy configuration is utilized via WinINet. However,
    // if WinINet is not working properly, this will be used by the Urllib
    // downloader, which acts as a fallback.
    "http_proxy": "proxy-url:proxy-port",
    // An HTTPS proxy server to use for requests - this will inherit from
    // http_proxy if it is set to "" or null and http_proxy has a value. You
    // can set this to false to prevent inheriting from http_proxy. Not
    // normally used on Windows since the system proxy configuration is
    // utilized via WinINet. However, if WinINet is not working properly, this
    // will be used by the Urllib downloader, which acts as a fallback.
    "https_proxy": "proxy-url:proxy-port",

    // Username and password for both http_proxy and https_proxy. May be used
    // with WinINet to set credentials for system-level proxy config.
    "proxy_username": "username",
    "proxy_password": "password",
}

clipboard.png

相关文章
相关标签/搜索