Mac终端代理和git代理设置

Mac终端代理设置

使用的s s代理

1.临时代理
在终端中输入

export http_proxy="http://127.0.0.1:1087"   
export https_proxy="http://127.0.0.1:1087"
或者直接
export all_proxy="http://127.0.0.1:1087"// 这是直接设置了http/https省得麻烦,当然你要是有分开设置的需求就分开设置

这是代理本身走的https/http
或者

export http_proxy="socks5://127.0.0.1:1086"   
export https_proxy="socks5://127.0.0.1:1086"
或者
export all_proxy="socks5://127.0.0.1:1086" // 这是直接设置了http/https省得麻烦,当然你要是有分开设置的需求就分开设置

这是代理本身走的socks5
2.永久写入
如果使用的是zsh就在.zshrc中写入

export http_proxy="http://127.0.0.1:1087"   
export https_proxy="http://127.0.0.1:1087"
或者
export http_proxy="socks5://127.0.0.1:1086"   
export https_proxy="socks5://127.0.0.1:1086"
或者
export all_proxy="socks5://127.0.0.1:1086"
或者
export all_proxy="http://127.0.0.1:1087"

3.取消代理

unset http_proxy // 取消http代理
unset https_proxy // 取消https代理
或者直接全部取消
unset ALL_PROXY

4.验证代理是否成功(查看公网ip和所在地址)
终端输入

curl ip.gs

你会看到


Mac终端代理和git代理设置_第1张图片
a.png

当然了你要是只想看ip就输入

curl ip.sb

就直接显示你在公网上的ip

注:ifconfig是查看本机在局域网内的ip,不是公网ip

你要是装了istat menus直接点击顶栏的网络部分就可以查看局域网ip和公网ip

当然了我更推荐用alias自定义命令

像这样(我用的zsh所以是在.zshrc文件中写入)

alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1086"
alias setproxyhttp="export ALL_PROXY=http://127.0.0.1:1087"
alias unsetproxy="unset ALL_PROXY"

这样你只需要输入setproxy或者setproxyhttp就行了,取消的话就unsetproxy就好了
你也可以单独给git设置代理

alias agent="git config --global http.proxy socks5://127.0.0.1:1086;git config --global https.proxy socks5://127.0.0.1:1086;git config --global http.sslVerify false"
alias unagent="git config --global --unset http.proxy;git config --global --unset https.proxy"
或者
alias agent="git config --global http.proxy http://127.0.0.1:1087;git config --global https.proxy http://127.0.0.1:1087;git config --global http.sslVerify false"
alias unagent="git config --global --unset http.proxy;git config --global --unset https.proxy"

使用和取消同上,啦啦啦,大家好好玩耍吧

你可能感兴趣的:(Mac终端代理和git代理设置)