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

相關文章
相關標籤/搜索