Skip to content

Instantly share code, notes, and snippets.

@grocky
Forked from manekinekko/set_proxy.sh
Last active August 29, 2015 14:06
Show Gist options
  • Save grocky/e38c017f7b4177130d01 to your computer and use it in GitHub Desktop.
Save grocky/e38c017f7b4177130d01 to your computer and use it in GitHub Desktop.
#! /bin/sh
proxy=$PROXY
if [ "$1" == "on" ]; then
echo "exporting proxy"
export http_proxy=$proxy
export https_proxy=$proxy
echo "setting git proxy to $proxy"
git config --global http.proxy $proxy
git config --global https.proxy $proxy
echo "setting npm proxy to $proxy"
npm config set proxy $proxy
npm config set https-proxy $proxy
echo "setting bower proxy to $proxy"
sed -i.bak 's|"proxy": ""|"proxy": "'"$proxy"'"|g' $HOME/.bowerrc
sed -i.bak 's|"https-proxy": ""|"https-proxy": "'"$proxy"'"|g' $HOME/.bowerrc
echo "setting Package Control proxy to $proxy"
sed -i.bak 's|"http_proxy": ""|"http_proxy": "'"$proxy"'"|g' "$home/AppData/Roaming/Sublime Text 3/Packages/User/Package Control.sublime-settings"
sed -i.bak 's|"https_proxy": ""|"https_proxy": "'"$proxy"'"|g' "$home/AppData/Roaming/Sublime Text 3/Packages/User/Package Control.sublime-settings"
else
echo "resetting proxy"
export http_proxy=
export https_proxy=
echo "resetting git proxy..."
git config --global --unset http.proxy > /dev/null 2>&1
git config --global --unset https.proxy > /dev/null 2>&1
echo "resetting npm proxy..."
npm config rm proxy > /dev/null 2>&1
npm config rm https-proxy > /dev/null 2>&1
echo "resetting bower proxy..."
sed -i.bak 's|"proxy": "'"$proxy"'"|"proxy": ""|g' $HOME/.bowerrc
sed -i.bak 's|"https-proxy": "'"$proxy"'"|"https-proxy": ""|g' $HOME/.bowerrc
echo "resetting Package Control proxy..."
sed -i.bak 's|"http_proxy": "'"$proxy"'"|"http_proxy": ""|g' "$home/AppData/Roaming/Sublime Text 3/Packages/User/Package Control.sublime-settings"
sed -i.bak 's|"https_proxy": "'"$proxy"'"|"https_proxy": ""|g' "$home/AppData/Roaming/Sublime Text 3/Packages/User/Package Control.sublime-settings"
fi
@manekinekko
Copy link

Good job!
Is this for Windows right ?

@grocky
Copy link
Author

grocky commented Mar 10, 2015

Thanks! Yea, this was for a cygwin setup. But the only think that is windows specific is the location of the SublimeText settings.

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