~/.bashrc 不在公司代理后面工作

~/.bashrc not working behind corporate proxy

这里是我写的脚本在~/.bashrc

(curl https://google.com -m 2 && clear) || (export HTTPS_PROXY='http://username:password@http-mycompany.com:8080' && echo "done")

这基本上是为了在我使用 VPN 时使用 git bash 设置代理,否则 :)

The output whenever I open the git bash when in vpn

同样,当我执行 "echo $HTTPS_PROXY" 时,输出不显示代理 URL

我是不是漏掉了什么,它实际上更早工作了:p

(如果有帮助 OS:Windows 10,git 版本 - 2.15)

also when I do "echo $HTTPS_PROXY" the output doesn't show the proxy URL

那是因为 HTTPs_PROXY 设置在 ( ) 表达式中的 sub-shell 中。之后就丢失了。

最好避免那些(), as in here:

curl https://google.com -m 2
if [ 0 -eq $? ]; then
  export HTTP_PROXY=http://username:password@http-mycompany.com:8080
  export HTTPS_PROXY=http://username:password@http-mycompany.com:8080
  export NO_PROXY=mycompany.com,.sock,localhost,127.0.0.1,::1,.local
  echo "done"
fi

注意:最好同时定义HTTP_PROXYNO_PROXY