Last active
September 4, 2018 20:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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