Last active
May 4, 2019 12:35
-
-
Save manekinekko/2b4a29fe35c292b6f72f to your computer and use it in GitHub Desktop.
Toggling Proxy Settings for Git, NPM, Bower and Package Control (Mac OS X) automatically
This file contains hidden or 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 | |
proxy="YOUR_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/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings" | |
sed -i.bak 's|"https_proxy": ""|"https_proxy": "'"$proxy"'"|g' "$HOME/Library/Application Support/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/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings" | |
sed -i.bak 's|"https_proxy": "'"$proxy"'"|"https_proxy": ""|g' "$HOME/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Merci Cedric, je vais étudier tes modifs.