Codementor Events

Toggle proxies in macOS Terminal

Published Jun 22, 2019

One of the biggest annoyance in macOS's UI is the relative unease of switching between normal internet and a proxied connection. You have to:

1. Go to "System Preferences"
2. Go to "Networking"
3. Click your connection (Probably Ethernet or Wi-Fi)
4. Click "Advanced"
5. Click "Proxies"
6. Click "Web Proxy" and enter your info if its the first time setting up and check the box
7. Click "Secure Web Proxy" and enter your info if its the first time setting up and check the box
8. Click "OK"
9. Click "Apply"

Nine-friggin-steps just to toggle your proxy?!?! I won't accept this as a part of my workflow, and neither should you.

Thankfully, a dude named sryze wrote a quick bash script to handle toggling for us:

https://gist.github.com/sryze/1f77d803023b9586e6c565b634e10787

I've forked their gist and updated it to be more generalized:

https://gist.github.com/mikedesu/6b0040bd419c900d11c07f11edb2ce1e

For me, toggling on or off is now a one-line command:

$ ./proxy.sh Wi-Fi 8080 on
$ ./proxy.sh Wi-Fi 8080 off

Frequently, I'll just have to press "up up enter" in the terminal, which is something my right-hand can do all by itself! 😄

Feels good to take this massive annoying process and reduce it to a few button presses.

Now I can get back to hunting for bugs with ease!

Discover and read more posts from Mike Bell
get started
post commentsBe the first to share your opinion
Show more replies