Skip to content

Instantly share code, notes, and snippets.

@tjluoma
Last active July 18, 2019 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjluoma/094f943342bdccb745b988ad5fb6238c to your computer and use it in GitHub Desktop.
Save tjluoma/094f943342bdccb745b988ad5fb6238c to your computer and use it in GitHub Desktop.
Assuming you have a Mac with both wired Ethernet and Wi-Fi, this will show you whether or not the http/https proxy is set for both
#!/bin/zsh -f
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
## Note:
## ETHERNET_REGULAR / WIFI_REGULAR means http
## ETHERNET_SECURE / WIFI_SECURE means https
ETHERNET_REGULAR=$(networksetup -getwebproxy Ethernet | awk -F' ' '/^Enabled:/{print $2}')
ETHERNET_SECURE=$(networksetup -getsecurewebproxy Ethernet | awk -F' ' '/^Enabled:/{print $2}')
WIFI_REGULAR=$(networksetup -getwebproxy Wi-Fi | awk -F' ' '/^Enabled:/{print $2}')
WIFI_SECURE=$(networksetup -getsecurewebproxy Wi-Fi | awk -F' ' '/^Enabled:/{print $2}')
if [ "$ETHERNET_REGULAR" = "" -a "$ETHERNET_SECURE" = "" ]
then
# if Ethernet is not found, assume we are on a Mac without wired Ethernet (read: "a MacBook (Air|Pro)")
if [ "$WIFI_REGULAR" = "Yes" -a "$WIFI_SECURE" = "Yes" ]
then
echo "Proxy ON"
elif [ "$WIFI_REGULAR" = "No" -a "$WIFI_SECURE" = "No" ]
then
echo "Proxy OFF"
else
echo "Proxy Mixed\nWi-Fi http: $WIFI_REGULAR\nWi-Fi https: $WIFI_SECURE"
fi
else
if [ "$ETHERNET_REGULAR" = "Yes" -a "$ETHERNET_SECURE" = "Yes" -a "$WIFI_REGULAR" = "Yes" -a "$WIFI_SECURE" = "Yes" ]
then
echo "Proxy ON"
elif [ "$ETHERNET_REGULAR" = "No" -a "$ETHERNET_SECURE" = "No" -a "$WIFI_REGULAR" = "No" -a "$WIFI_SECURE" = "No" ]
then
echo "Proxy OFF"
else
echo "Proxy Mixed\nEthernet http: $ETHERNET_REGULAR\nEthernet https: $ETHERNET_SECURE\nWiFi http: $WIFI_REGULAR\nWifi https: $WIFI_SECURE"
fi
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment