Skip to content

Instantly share code, notes, and snippets.

@jameswomack
Last active September 4, 2018 20:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jameswomack/8413719 to your computer and use it in GitHub Desktop.
Save jameswomack/8413719 to your computer and use it in GitHub Desktop.
Bash/ZSH for changing git/npm/global proxy info based on current Wifi SSID on Mac
alias airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
CURRENT_WIFI_SSID=$(eval airport -I | grep '^[[:space:]]*SSID' | sed -e 's/^.*SSID: //g')
proxy() {
export addy='http://www-west.sony.com:80'
git config --global http.proxy $addy
git config --global https.proxy $addy
npm config set http-proxy $addy
npm config set https-proxy $addy
export HTTP_PROXY=$addy
export HTTPS_PROXY=$addy
export http_proxy=$HTTP_PROXY
echo 'Using proxy'
}
noproxy() {
export addy=''
git config --global --unset-all http.proxy
git config --global --unset-all https.proxy
npm config delete http-proxy
npm config delete https-proxy
export HTTP_PROXY=$addy
export HTTPS_PROXY=$addy
export http_proxy=$HTTP_PROXY
echo 'Not using proxy'
}
[[ $CURRENT_WIFI_SSID != 'SWing' ]] && noproxy > /dev/null
[[ $CURRENT_WIFI_SSID == 'SWing' ]] && proxy > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment