• 主页
  • 系列总集
  • OpenCV
  • CMake
  • iOS
  • Java
  • 前端
所有文章 关于我

  • 主页
  • 系列总集
  • OpenCV
  • CMake
  • iOS
  • Java
  • 前端

终端下为npm和git配置Shadowsocks

2016-12-18

终端下的代理

通过文章MacOS 10.12 终端命令行下使用Shadowsocks我们得知Shadowsocks-NG可以提供HTTP和HTTPS代理了,那么我们可以单独为某些命令配置代理

为npm配置代理

参考文章npm的配置文件npmrc,我们可以在Mac下新建一个配置文件

1
vim ~/.npmrc

在文件内写入

1
2
proxy = http://127.0.0.1:1087
https-proxy = http://127.0.0.1:1087

然后保存退出即可,如果想使用命令直接配置,参考文章命令配置npmrc,其中也对配置文件进行更详细的解释

npm获取配置有6种方式,优先级由高到底

  1. 命令行参数。 –proxy http://server:port即将proxy的值设为http://server:port。
  2. 环境变量。 以npm_config_为前缀的环境变量将会被认为是npm的配置属性。如设置proxy可以加入这样的环境变量npm_config_proxy=http://server:port。
  3. 用户配置文件。可以通过npm config get userconfig查看文件路径。如果是mac系统的话默认路径就是$HOME/.npmrc。
  4. 全局配置文件。可以通过npm config get globalconfig查看文件路径。mac系统的默认路径是/usr/local/etc/npmrc。
  5. 内置配置文件。安装npm的目录下的npmrc文件。
  6. 默认配置。 npm本身有默认配置参数,如果以上5条都没设置,则npm会使用默认配置参数。

为Git配置代理

首先Git分为3种协议模式

协议 是否可以使用HTTP代理
git:// 不能直接使用
http:// 可以
https:// 可以

命令行配置

1
2
3
4
5
6
7
8
//配置
git config --global core.gitproxy proxy
git config --global http.proxy http://127.0.0.1:1087
git config --global https.proxy https://127.0.0.1:1087
//取消
git config --global --unset core.gitproxy
git config --global --unset http.proxy
git config --global --unset https.proxy

修改配置文件

git的配置文件位于

1
vim ~/.gitconfig

如果我们进行了代理配置,可以看到

1
2
3
4
5
6
[core]
gitproxy = proxy
[http]
proxy = http://127.0.0.1:1087
[https]
proxy = https://127.0.0.1:1087
赏

请问老板还招人么(/ω\)

支付宝
微信
  • Terminal
  • FireWall
  • Tips

扫一扫,分享到微信

微信分享二维码
Java多线程预习小笔记
MacOS 10.12 终端命令行下使用Shadowsocks
© 2021 Alan Li
Hexo Theme Yilia by Litten
  • 所有文章
  • 关于我

tag:

  • iOS
  • Java
  • Collection
  • Python
  • Shell
  • CMake
  • Memory
  • JavaScript
  • Architecture
  • AnchorPoint
  • Android
  • Web
  • Annotation
  • AFNetworking
  • Window
  • ViewController
  • AutoLayout
  • Dozer
  • CoreAnimation
  • Cycle Retain
  • Block
  • UI
  • IDE
  • FrontEnd
  • CSS
  • Category
  • TableViewCell
  • Security
  • Net
  • JSP
  • Spring
  • C
  • MyBatis
  • Date
  • React
  • GCD
  • UITouch
  • Gesture
  • UIControl
  • Git
  • HTML
  • HTTPS
  • HTTP
  • Servlet
  • Server
  • DataBase
  • MySQL
  • Linux
  • Tutorial
  • Ajax
  • Type
  • JQuery
  • JSON
  • Exception
  • Parameter
  • Reflect
  • Thread
  • Sort
  • KVO
  • MKMapKit
  • Overlay
  • Maven
  • Configure
  • Tips
  • Transaction
  • Swift
  • NavigationBar
  • Nginx
  • Runtime
  • OpenCV
  • Property
  • Playground
  • Protocol
  • Redux
  • ScrollView
  • Session
  • Cookie
  • Shiro
  • Error
  • Singleton
  • RegEx
  • StackView
  • StatusBar
  • Base64
  • Socket
  • TCP
  • IP
  • TextField
  • CALayer
  • UILabel
  • View
  • Animation
  • Xcode
  • Hexo
  • Terminal
  • OC
  • Device
  • Log
  • Image
  • JUnit
  • Oval
  • Archive
  • XSS
  • Compiler
  • Aspect
  • Responder
  • Class
  • FireWall
  • RetainCount
  • Const
  • Frame
  • String
  • Symbols
  • Framework
  • CocoaPods
  • Unity
  • Message
  • Button
  • AuthorizationStatus
  • Struct
  • XCTest
  • NSNotification
  • Contact

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

我写的,大概率是错的。。。。。