Clear Bash and Zsh Proxy Variables with an unproxy Function
Fix a shell helper that removes only all_proxy after enabling protocol-specific variables and uppercase ALL_PROXY.
This shell helper has an incomplete off switch:
export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087
export ALL_PROXY=socks5://127.0.0.1:1080
alias unproxy='unset all_proxy'
On a Unix shell, all_proxy and ALL_PROXY are different names. The alias removes none of the three variables above. Removing only uppercase ALL_PROXY would still leave the two protocol-specific settings.
To clear these common names from the current Bash or Zsh session:
unproxy() {
unset http_proxy https_proxy all_proxy
unset HTTP_PROXY HTTPS_PROXY ALL_PROXY
}
Invoke the function in the shell whose subsequent commands should inherit the cleaned environment. A child script cannot clean its parent terminal's environment.
Already running applications retain their own state. A curl configuration file, Git setting, browser preference, or explicit command option can also select a proxy after the variables are removed. If traffic still uses it, inspect that client's configuration.