-
-
Save mikedesu/6b0040bd419c900d11c07f11edb2ce1e 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 | |
# usage: ./proxy.sh <service> <port> <on/off> | |
SERVICE="$1" # or "Wi-Fi" | |
PROXY_HOST="127.0.0.1" | |
PROXY_PORT="$2" | |
case "$3" 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' | |
;; | |
off) | |
networksetup -setwebproxystate $SERVICE off | |
networksetup -setsecurewebproxystate $SERVICE off | |
echo 'Web proxy is off' | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment