Skip to content

Instantly share code, notes, and snippets.

@mikedesu mikedesu/proxy forked from sryze/proxy
Last active Jul 2, 2019

Embed
What would you like to do?
Quickly toggle HTTP(S) proxy on Mac OS X from command line
#!/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
You can’t perform that action at this time.