-
Notifications
You must be signed in to change notification settings - Fork 1
/
proxy
executable file
·44 lines (32 loc) · 1.53 KB
/
proxy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/sh
proxy=$http_proxy
if [ -z "$var" ]; then
echo 'FAILED: proxy is not set'
echo 'modify ~/.exports.sh or ~/.extras.sh to set it before running this command'
return 1
fi
if [[ "$1" == "on" ]]; then
echo "Setting proxies to $proxy"
export http_proxy=$proxy
export https_proxy=$proxy
export HTTP_PROXY=$proxy
export HTTPS_PROXY=$proxy
git config --global http.proxy $proxy &>/dev/null
git config --global https.proxy $proxy &>/dev/null
npm config set proxy $proxy &>/dev/null
npm config set https-proxy $proxy &>/dev/null
sed -i.bak 's|"proxy": ""|"proxy": "'"$proxy"'"|g' $HOME/.bowerrc &>/dev/null
sed -i.bak 's|"https-proxy": ""|"https-proxy": "'"$proxy"'"|g' $HOME/.bowerrc &>/dev/null
else
echo "Disabling proxies"
unset http_proxy
unset https_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
git config --global --unset http.proxy &>/dev/null
git config --global --unset https.proxy &>/dev/null
npm config rm proxy &>/dev/null
npm config rm https-proxy &>/dev/null
sed -i.bak 's|"proxy": "'"$proxy"'"|"proxy": ""|g' $HOME/.bowerrc &>/dev/null
sed -i.bak 's|"https-proxy": "'"$proxy"'"|"https-proxy": ""|g' $HOME/.bowerrc &>/dev/null
fi