Setting the proxy environment variable in zsh is crucial when working in a network environment that requires routing traffic through a proxy server. This configuration ensures that network commands like curl, wget, and system package managers use the proxy server to access external resources.
In zsh, the proxy environment variables include HTTP_PROXY and HTTPS_PROXY. These variables direct HTTP and HTTPS traffic to the appropriate proxy server. You can also set the NO_PROXY variable to bypass the proxy for certain domains or IP addresses.
The steps below outline how to set these proxy variables for both temporary use in the current session and permanently through the .zshrc configuration file.
$ export HTTP_PROXY=http://proxy.example.com:8080 $ export HTTPS_PROXY=https://proxy.example.com:8080
$ vim ~/.zshrc
$ export HTTP_PROXY=http://proxy.example.com:8080 $ export HTTPS_PROXY=https://proxy.example.com:8080 $ export NO_PROXY=localhost,127.0.0.1
Make sure to replace “proxy.example.com” and “8080” with the actual proxy details for your network.
$ source ~/.zshrc
$ echo $HTTP_PROXY http://proxy.example.com:8080 $ echo $HTTPS_PROXY https://proxy.example.com:8080