Skip to content

Instantly share code, notes, and snippets.

@siliconmeadow
Forked from tsphethean/proxy_switch.sh
Last active August 29, 2015 14:07
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 siliconmeadow/275d2b949e9d27eec0b5 to your computer and use it in GitHub Desktop.
Save siliconmeadow/275d2b949e9d27eec0b5 to your computer and use it in GitHub Desktop.
#!/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=https://$2
export HTTPS_PROXY=https://$2
git config --global http.proxy $2
npm config set proxy http://$2
npm config set https-proxy https://$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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment