How to Set Up a Network Proxy in Terminal Shell
Terminal Shell on OS does not use the system proxy, so even if the system proxy is enabled, commands like curl or npm in iTerm2 may still face network issues.
Proxy apps like Surge or others that support modifying the network card can force the terminal to use the proxy, but sometimes, we don’t want to use this method. So, Can the terminal shell use the proxy?
Yes, there is. Here is the solution.
Shell Configuration File
Here, take bash as an example. Open the bash_profile by vi/.bash_profile. If you usually use zsh, you can also
vi ~/.zshrc`.
Add the following configuration: