I frequently switch from inside a network that needs a proxy to being on public internet. Swapping the proxy on/off is less than easy for things like github so here’s the script I use.
The script uses the osx utility scutil with –proxy to get the current proxy configuration. Then it’s a simple if/then to set to unset various proxy settings.