MacOS – Command line (or other way) to change proxy config in easy way

keyboardmacosPROXYsettings

At the company I work at we use the proxies to connect to the Internet. This works fine until I have to do XCode simulator work(in UIWebView, not Safari browser), at which time I have to turn off all the proxies.

But if I do this, I can't connect to the Internet in my mac book. So, I have to change it frequently. It is so boring.

I have to frequently access this System Preference to change these settings:
enter image description here

So, there are any easy way to change it with a keyboard shortcut? Can I create a command line script and start it with a keyboard shortcut? Is there a way to make the XCode simulator work with a proxy? Any ideas?

Best Answer

No need to create a script:

  1. Create a proxyless network environment: in the Network pane of System Preferences, click on the “Profile” drop down and select “Manage Profiles…”. Duplicate your standard settings (by clicking on the cog wheel button at the bottom of the list). Give the duplicated profile a unique name (“Proxyless”, say). Disable all proxies in the settings for that profile.
  2. Assign a keyboard shortcut to your new profile: in the Keyboard pane of System Preferences, create a new Application shortcut for “All Applications”. Name it like your profile (i.e. “Proxyless”), add the shortcut.

The shortcut will be activated once your switch applications at least once (it won’t be active while you are still in System Preferences).