Apple - How to set proxy on OS X Terminal permanently?
Your http proxy (just for some web sites not https ones and not for the rest of the internet) can be set for each terminal session by adding the line
export http_proxy="username:password@ip address:port number"
to your ~/.bash_profile file
Note this will only affect command line programs.
To globally set an http proxy system-wide on MacOS (not just for the terminal) you can use:
networksetup -setwebproxy wi-fi localhost 8080
networksetup -setwebproxystate wi-fi on
This assumes your network interface is called
wi-fi
(orWi-Fi
), your proxy is running onlocalhost
on port8080
.
To disable the proxy:
networksetup -setwebproxystate wi-fi off
This is equivalent to setting the proxy via mac system settings > Network > wi-fi > Advanced > Proxies > Web proxy.
If you need a GUI wrapper for this command check out this answer.