跳至主要内容

Win/Linux 命令行、终端和 Git 代理设置

本文整理了 Windows 命令行 和 Linux 终端以及 Git 中设置代理的命令。以本地 HTTP/HTTPS 代理 127.0.0.1:8118 和 SOCKS5 代理 127.0.0.1:1080 为例。

Windows 命令行代理设置

HTTP 代理设置:
set http_proxy=http://127.0.0.1:8118
set https_proxy=http://127.0.0.1:8118
SOCKS5 代理设置:
set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080
可以通过 echo %http_proxy% 命令查看是否设置成功。
取消代理设置:
set http_proxy=
set https_proxy=

Linux 终端代理设置

临时代理设置

Linux 终端设置 HTTP 代理(只对当前终端有效):
$ export http_proxy=http://127.0.0.1:8118
$ export https_proxy=http://127.0.0.1:8118
Linux 中设置 SOCKS5 代理(只对当前终端有效):
$ export http_proxy=socks5://127.0.0.1:1080
$ export https_proxy=socks5://127.0.0.1:1080
设置终端中的 wget、curl 等都走 SOCKS5 代理(只对当前终端有效):
$ export ALL_PROXY=socks5://127.0.0.1:1080
Linux 终端中取消代理设置:
$ unset http_proxy
$ unset https_proxy
$ unset ALL_RPOXY

永久代理设置

将代理命令写入配置文件 ~/.profile~/.bashrc~/.zshrc 中:
# HTTP 代理设置
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118
# SOCKS5 代理设置
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=socks5://127.0.0.1:1080
# 强制终端中的 wget、curl 等都走 SOCKS5 代理
export ALL_PROXY=socks5://127.0.0.1:1080

Git 设置代理

代理格式 [protocol://][user[:password]@]proxyhost[:port]
参考 https://git-scm.com/docs/git-config
设置 HTTP 代理:
git config --global http.proxy http://127.0.0.1:8118
git config --global https.proxy http://127.0.0.1:8118
设置 SOCKS5 代理:
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
Git 取消代理设置:
git config --global --unset http.proxy
git config --global --unset https.proxy

评论

此博客中的热门博文

VMware Workstation 10安装Mac OS X Mountain Lion 10.8.5

关于原版OS X Mountain Lion 10.8.5 Mac OS X Mountain Lion 10.8.5作为Mountain Lion的最后一个稳定版本值得我们收藏。可能大家有所不知,10.8.5版本是分为两个Build的,一个是在2013年9月13日发布的 10.8.5 Build 12F37 ,另一个是2013年10月3日发布的 10.8.5 Build 12F45 。也就是说, 10.8.5 Build 12F45 才是Mountain Lion的最终版本。 OS X Mountain Lion的维基百科 不幸的是,网友们和论坛中分享的 OS X Mountain Lion 10.8.5 正式版 原版完整DMG安装镜像 大多数是Build 12F37版本(从发帖日期就可以看出来),网上搜索到的种子文件也是Build 12F37的种子。要想下载原版Build 12F45,可以搜索 OSX1085-12F45-ESD.dmg ,或者从这里下载: http://pan.baidu.com/s/1f68Vv 怎么知道下载了哪个版本? 通过文件的MD5等校验值来辨别。使用软件: Hash 或者 HashTab 。 OS X Mountain Lion 10.8.5 Build 12F37.dmg 信息如下: 大小: 4469250353 字节 MD5: 5568B4DDE00A64F765EF00858B538078 SHA1: ECF68C2119C71825839D2A58E0D619E9CCF7C026 CRC32: F4DFCE4D 从中提取出的InstallESD.dmg: MD5: 2C77151BE45C820B02A9ACE05434693D SHA1: 2919B519142E2119197BFFD678F15F603E84970F CRC32: A9DCAE18 OSX1085-12F45-ESD.dmg 信息如下: 大小: 4448808132 字节 MD5: 3FCEBFC81D00767D1ACEF1CB166F88CC SHA1: 98E52D0FC443940265780539A311833EE5814DDD CRC32: C82F14C1 从中提取出的InstallESD.dmg: 大小: 443...

网盘端到端加密 Cryptomator

1. Crytomator 是什么 Cryptomator 是一款开源的文件加密工具,它支持在本地硬盘上创建多个加密仓库,这些加密仓库以文件卷(硬盘卷)的形式挂载到系统目录中,存放到文件卷中的文件都会自动加密。 如果把加密仓库的目录放到网盘的同步目录下,配合如 iCloud、Dropbox、OneDrive、坚果云 等云盘使用,就能达到端到端加密同步的效果。 2. 同类工具对比 同类的文件加密工具除 Cryptomator 之外,还有 gocryptfs、encfs 等。其中 Cryptomator 使用 Java 开发,而且提供了 macOS、Windows、Linux、iOS 和 Android 上个 GUI 版本,从易用性上来说体验最佳。 gocryptfs v1.7 encfs v1.9.5 ecryptfs v4.19.0 cryptomator v1.4.6 securefs v0.8.3 CryFS v0.10.0 First release 2015 ( ref ) 2003 ( ref ) 2006 ( ref ) 2014 ( ref ) 2015 ( ref ) 2015 ( ref ) Language Go C++ C Java C++ C++ License MIT ( ref ) LGPLv3 / GPLv3 ( ref ) GPLv2 GPLv3 ( ref ) MIT ( ref ) LGPLv3 ( ref ) Development hotspot Austria USA USA (RedHat) Germany China Germany Lifecycle Active Maintenance Active ( ref ) Active Active Active File interface FUSE FUSE In-kernel filesystem FUSE/WebDAV FUSE FUSE Platforms Linux, macOS, 3rd-party Windows port,3rd-party Android port Linux, macOS, 3rd-par...

终端折腾记

最新更新时间 2019-06-20 Oh-My-Zsh 安装 前提是需要安装 zsh git curl : sudo apt install zsh curl git sh -c " $(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh) " 比较推荐的插件如下,需要修改 ~/.zshrc 配置文件: plugins=( git z extract zsh-autosuggestions # 需要自己安装 zsh-syntax-highlighting # 需要自己安装 ) 为 oh-my-zsh 安装 zsh-autosuggestions: git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM /plugins/zsh-autosuggestions 为 oh-my-zsh 安装 zsh-syntax-highlighting: git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom} /plugins/zsh-syntax-highlighting Oh-My-Zsh 的主题 我更偏爱 powerlevel9k 主题,可以定制的地方很多 https://github.com/bhilburn/powerlevel9k 但是, powerlevel9k 主题对字体的配置比较麻烦,如果使用这个主题,一定要配置好下面提到的 必需的字体 。 主题安装 https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#step-1-install-powerlevel9k 为 Oh-My-ZSH 安装主题: git clone https://github.com/bhilburn/powerlevel9k.git ~...