Last active
February 22, 2025 15:52
-
-
Save m3rkus/82761a3e2c0c3021a1e75268db594427 to your computer and use it in GitHub Desktop.
Script for convenient enabling/disabling proxy settings on your Mac OS machine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
proxy
with content from above code snippetusr/local/bin
chmod +x /usr/local/bin/proxy
proxy [on/off]