Skip to content

Instantly share code, notes, and snippets.

@mikedesu
Forked from sryze/proxy
Last active July 2, 2019 14:52
Show Gist options
  • Save mikedesu/6b0040bd419c900d11c07f11edb2ce1e to your computer and use it in GitHub Desktop.
Save mikedesu/6b0040bd419c900d11c07f11edb2ce1e to your computer and use it in GitHub Desktop.
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