Skip to content

Instantly share code, notes, and snippets.

@m3rkus
Last active March 1, 2024 17:52
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m3rkus/82761a3e2c0c3021a1e75268db594427 to your computer and use it in GitHub Desktop.
Save m3rkus/82761a3e2c0c3021a1e75268db594427 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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