Skip to content

Instantly share code, notes, and snippets.

@m3rkus

m3rkus/proxy.sh

Last active Nov 23, 2020
Embed
What would you like to do?
Script for convenient enabling/disabling proxy settings on your Mac OS machine.
#!/bin/bash
NETWORK_SERVICE_NAME="Wi-Fi"
if [ "$#" -ne 1 ]; then
echo "Argument missing [on/off]"
exit 0
fi
if [ $1 == "on" ]; then
networksetup -setwebproxystate "$NETWORK_SERVICE_NAME" on
networksetup -setsecurewebproxystate "$NETWORK_SERVICE_NAME" on
echo "Enabled proxy for $NETWORK_SERVICE_NAME"
elif [ $1 == "off" ]; then
networksetup -setwebproxystate "$NETWORK_SERVICE_NAME" off
networksetup -setsecurewebproxystate "$NETWORK_SERVICE_NAME" off
echo "Disabled proxy for $NETWORK_SERVICE_NAME"
else
echo "Argument invalid [permitted:on/off]"
fi
@m3rkus

This comment has been minimized.

Copy link
Owner Author

@m3rkus m3rkus commented Apr 3, 2018

Usage:

  1. Create file proxy with content from above code snippet
  2. Place file in your usr/local/bin
  3. Give this file permission to be executed chmod +x /usr/local/bin/proxy
  4. Call it from your command line like this: proxy [on/off]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment