-
Notifications
You must be signed in to change notification settings - Fork 1
/
.switch-proxy.osx
executable file
·50 lines (41 loc) · 1.07 KB
/
.switch-proxy.osx
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
45
46
47
48
49
50
proxy=http://proxy.example.com:4444/
switch_trigger=workspace
function set_proxy() {
export http_proxy=$proxy
export HTTP_PROXY=$proxy
export ftp_proxy=$proxy
export FTP_PROXY=$proxy
export all_proxy=$proxy
export ALL_PROXY=$proxy
export https_proxy=$proxy
export HTTPS_PROXY=$proxy
git config --global http.proxy $proxy
git config --global https.proxy $proxy
# echo "" > ~/.npmrc
# echo "https-proxy=${proxy}/" >> ~/.npmrc
# echo "registry=http://registry.npmjs.org/" >> ~/.npmrc
# echo "proxy=${proxy}/" >> ~/.npmrc
export no_proxy="localhost, 192.168.0.0/16"
export NO_PROXY="$no_proxy"
}
function unset_proxy() {
unset http_proxy
unset HTTP_PROXY
unset ftp_proxy
unset FTP_PROXY
unset all_proxy
unset ALL_PROXY
unset https_proxy
unset HTTPS_PROXY
git config --global --unset http.proxy
git config --global --unset https.proxy
# echo "" > ~/.npmrc
unset no_proxy
unset NO_PROXY
}
if [ "`networksetup -getcurrentlocation`" = "$switch_trigger" ]; then
echo "Switch to proxy for office network"
set_proxy
else
unset_proxy
fi