Proxy switchy script
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
#!/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 |
export / unset depends upon the shell youre using. I'm on the iterm2 default and export worked but unset didn't.
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
The disabling of shell proxies didn't work for me recently.
Instead of setting the variables to empty, I think we need to use 'unset'.
i.e.