命令行使用代理

  1. 修改.zshrc

    1
    vim ~/.zshrc
  2. alias区块下添加如下内容,代理地址记得填写你自己的

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    alias proxy="
    export http_proxy=socks5://127.0.0.1:1090;
    export https_proxy=socks5://127.0.0.1:1090;
    export all_proxy=socks5://127.0.0.1:1090;
    export no_proxy=socks5://127.0.0.1:1090;
    export HTTP_PROXY=socks5://127.0.0.1:1090;
    export HTTPS_PROXY=socks5://127.0.0.1:1090;
    export ALL_PROXY=socks5://127.0.0.1:1090;
    export NO_PROXY=socks5://127.0.0.1:1090;"
    alias unproxy="
    unset http_proxy;
    unset https_proxy;
    unset all_proxy;
    unset no_proxy;
    unset HTTP_PROXY;
    unset HTTPS_PROXY;
    unset ALL_PROXY;
    unset NO_PROXY"
  3. 测试一下

    1
    2
    3
    4
    5
    $ curl https://ip.cn
    >> {"country": "山西省临汾市", "city": "移动"}
    $ proxy
    $ curl https://ip.cn
    >> {"country": "美国", "city": "Choopa"}