Terminal environment variables

Proxy variables for bash, zsh, fish, PowerShell and cmd.

Most command-line tools read http_proxy / https_proxy / all_proxy (some use upper case, some lower case, so set both).

bash / zsh

bash
export http_proxy=http://127.0.0.1:7898
export https_proxy=http://127.0.0.1:7898
export all_proxy=socks5://127.0.0.1:7898
export HTTP_PROXY=$http_proxy HTTPS_PROXY=$https_proxy ALL_PROXY=$all_proxy
export no_proxy=localhost,127.0.0.1,::1
export NO_PROXY=$no_proxy

As on/off functions in ~/.zshrc or ~/.bashrc:

bash
proxy_on()  { export http_proxy=http://127.0.0.1:7898 https_proxy=http://127.0.0.1:7898 all_proxy=socks5://127.0.0.1:7898; export HTTP_PROXY=$http_proxy HTTPS_PROXY=$https_proxy ALL_PROXY=$all_proxy; echo "proxy on"; }
proxy_off() { unset http_proxy https_proxy all_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY; echo "proxy off"; }

On Linux you can simply run:

bash
eval "$(cnb env)"          # set
eval "$(cnb env --unset)"  # unset

fish

fish
set -gx http_proxy http://127.0.0.1:7898
set -gx https_proxy http://127.0.0.1:7898
set -gx all_proxy socks5://127.0.0.1:7898
# Linux
cnb env --shell fish | source

Windows PowerShell

powershell
$env:HTTP_PROXY  = "http://127.0.0.1:7898"
$env:HTTPS_PROXY = "http://127.0.0.1:7898"
$env:NO_PROXY    = "localhost,127.0.0.1"

Windows cmd

bat
set HTTP_PROXY=http://127.0.0.1:7898
set HTTPS_PROXY=http://127.0.0.1:7898

Verify

bash
curl -sI https://github.com | head -1