Skip to content

Instantly share code, notes, and snippets.

@tsphethean
Last active August 29, 2015 13:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tsphethean/9684265 to your computer and use it in GitHub Desktop.
Save tsphethean/9684265 to your computer and use it in GitHub Desktop.
Proxy switchy script
#!/bin/sh
if [[ -z "$1" ]]; then
echo "Usage: proxy_switch.sh en 1.1.1.1:8080.
proxy_switch.sh dis"
exit 2;
fi
if [[ "$1" == "en" ]]; then
export http_proxy=http://$2
export https_proxy=http://$2
export HTTP_PROXY=http://$2
export HTTPS_PROXY=http://$2
git config --global http.proxy $2
npm config set proxy http://$2
npm config set https-proxy http://$2
elif [[ "$1" == "dis" ]]; then
export http_proxy=
export https_proxy=
export HTTP_PROXY=
export HTTPS_PROXY=
git config --global http.proxy ""
npm config delete proxy
npm config delete https-proxy
fi
@iainp999
Copy link

Unusually, in my case (I'm using zsh btw) setting the variables to empty doesn't work though, so we maybe need something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment