1

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

git

设置代理:

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

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

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

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

如果代理不支持https的话需要修改npm存放package的网站地址:

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

使用nrm管理切换npm源

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

Package Control

安装package control

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

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。

在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


zollero
3.8k 声望2.2k 粉丝