Last active
September 3, 2023 10:20
-
-
Save sryze/1f77d803023b9586e6c565b634e10787 to your computer and use it in GitHub Desktop.
Quickly toggle HTTP(S) proxy on Mac OS X from command line
This file contains 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/sh | |
SERVICE="Ethernet" # or "Wi-Fi" | |
PROXY_HOST="127.0.0.1" | |
PROXY_PORT="8888" | |
while [[ $# > 0 ]] | |
do | |
case "$1" in | |
on) | |
networksetup -setwebproxystate $SERVICE on | |
networksetup -setwebproxy $SERVICE $PROXY_HOST $PROXY_PORT off | |
networksetup -setsecurewebproxystate $SERVICE on | |
networksetup -setsecurewebproxy $SERVICE $PROXY_HOST $PROXY_PORT off | |
echo 'Web proxy is on' | |
shift | |
;; | |
off) | |
networksetup -setwebproxystate $SERVICE off | |
networksetup -setsecurewebproxystate $SERVICE off | |
echo 'Web proxy is off' | |
shift | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you check to see if this works with the external usb ethernet adaptor that's listed above (USB 10/100/1000 LAN)? Assuming the web proxy is turned on for the usb ethernet adaptor, if i then perform the following in terminal:
networksetup -setwebproxystate "USB 10/100/1000 LAN" off
Then check the usb ethernet adaptor it doesn't turn off the web proxy. I'm running osx v12.6.3.