Skip to content

Instantly share code, notes, and snippets.

@Cloudxtreme
Forked from jameswomack/proxy_switch.sh
Created September 4, 2018 20:59
Show Gist options
  • Save Cloudxtreme/d6f79a54be13060bb6d61dd05d54a859 to your computer and use it in GitHub Desktop.
Save Cloudxtreme/d6f79a54be13060bb6d61dd05d54a859 to your computer and use it in GitHub Desktop.

Revisions

  1. @jameswomack jameswomack revised this gist Jan 14, 2014. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions proxy_switch.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ alias airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/C
    CURRENT_WIFI_SSID=$(eval airport -I | grep '^[[:space:]]*SSID' | sed -e 's/^.*SSID: //g')

    proxy() {
    local addy='http://www-west.sony.com:80'
    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
    @@ -15,15 +15,16 @@ 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
    unset HTTP_PROXY
    unset HTTPS_PROXY
    unset http_proxy
    export HTTP_PROXY=$addy
    export HTTPS_PROXY=$addy
    export http_proxy=$HTTP_PROXY
    echo 'Not using proxy'
    }

    [[ $CURRENT_WIFI_SSID != 'SWing' ]] && "$(noproxy)" 2> /dev/null
    [[ $CURRENT_WIFI_SSID == 'SWing' ]] && "$(proxy)" 2> /dev/null
    [[ $CURRENT_WIFI_SSID != 'SWing' ]] && noproxy > /dev/null
    [[ $CURRENT_WIFI_SSID == 'SWing' ]] && proxy > /dev/null
  2. @jameswomack jameswomack revised this gist Jan 14, 2014. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions proxy_switch.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ alias airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/C
    CURRENT_WIFI_SSID=$(eval airport -I | grep '^[[:space:]]*SSID' | sed -e 's/^.*SSID: //g')

    proxy() {
    local addy='http://www.proxy.com:3000'
    local 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
    @@ -25,6 +25,5 @@ noproxy() {
    echo 'Not using proxy'
    }

    [[ $CURRENT_WIFI_SSID != 'YourSSID' ]] && echo "$(noproxy)"
    [[ $CURRENT_WIFI_SSID == 'YourSSID' ]] && echo "$(proxy)"

    [[ $CURRENT_WIFI_SSID != 'SWing' ]] && "$(noproxy)" 2> /dev/null
    [[ $CURRENT_WIFI_SSID == 'SWing' ]] && "$(proxy)" 2> /dev/null
  3. @jameswomack jameswomack revised this gist Jan 14, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions proxy_switch.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    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() {
  4. @jameswomack jameswomack created this gist Jan 14, 2014.
    28 changes: 28 additions & 0 deletions proxy_switch.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    CURRENT_WIFI_SSID=$(eval airport -I | grep '^[[:space:]]*SSID' | sed -e 's/^.*SSID: //g')

    proxy() {
    local addy='http://www.proxy.com:3000'
    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() {
    git config --global --unset-all http.proxy
    git config --global --unset-all https.proxy
    npm config delete http-proxy
    npm config delete https-proxy
    unset HTTP_PROXY
    unset HTTPS_PROXY
    unset http_proxy
    echo 'Not using proxy'
    }

    [[ $CURRENT_WIFI_SSID != 'YourSSID' ]] && echo "$(noproxy)"
    [[ $CURRENT_WIFI_SSID == 'YourSSID' ]] && echo "$(proxy)"