Skip to content

Instantly share code, notes, and snippets.

@ceaser
Created May 1, 2014 17:22
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 ceaser/7edb5c67c650092cd00a to your computer and use it in GitHub Desktop.
Save ceaser/7edb5c67c650092cd00a to your computer and use it in GitHub Desktop.
Detecting if a proxy is used for the active Network Location on a specific adaptor
if [ "`networksetup -getwebproxy 'USB Ethernet' | awk {'print $2'} | head -n 1 | tr -d ' '`" = "Yes" ]; then
export HTTP_PROXY=`networksetup -getwebproxy 'USB Ethernet' | awk {'print $2'} | awk {'getline l2; getline l3; print "http://"l2":"l3'} | head -n 1`
export HTTPS_PROXY=$HTTP_PROXY
export ALL_PROXY=$HTTP_PROXY
export http_proxy=$HTTP_PROXY
export https_proxy=$HTTP_PROXY
export all_proxy=$HTTP_PROXY
echo "Using $HTTP_PROXY as a Proxy"
else
unset HTTP_PROXY
unset HTTPS_PROXY
unset ALL_PROXY
unset http_proxy
unset https_proxy
unset all_proxy
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment