Set HTTP(s) Proxy in Windows Command Line / MAC Terminal

MISCPROXY

Windows Command Line

In Windows Command Line environment (NOT powershell), you can use below commands to set http and https proxy.

set http_proxy=protocol://ip:port
set https_proxy=protocol://ip:port

For example, if you have a local socks 5 proxy (such as ShadowSocks), commands will be as below.

set http_proxy=socks5://127.0.0.1:1086
set https_proxy=socks5://127.0.0.1:1086

After setting, you can echo these variables to confirm.

echo %http_proxy%
echo %https_proxy%

Set variable as empty to cancel the proxy

set http_proxy=
set https_proxy=

MAC Terminal

export http_proxy=socks5://127.0.0.1:1086      # Set HTTP Proxy
export https_proxy=socks5://127.0.0.1:1086     # Set HTTPS Proxy
export all_proxy=socks5://127.0.0.1:1086       # Set HTTP & HTTPS Proxy

To cancel HTTP Proxy in MAC Terminal, use unset command

unset http_proxy 
unset https_proxy

These setting are only validated for current session, not impact system or other sessions.

PS: If your are running Shadowsocks, just disable system proxy instead of selecting mode as PAC or Global.