-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.switch_proxy
More file actions
36 lines (31 loc) · 959 Bytes
/
.switch_proxy
File metadata and controls
36 lines (31 loc) · 959 Bytes
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
url=your.proxy.name.jp:8080
user=your_user_name
password=your_user_password
proxy="http://${user}:${password}@${url}"
switch_trigger_location=KBTLAB
switch_trigger_network=KBTLAB
function set_proxy() {
export http_proxy=$proxy
export ftp_proxy=$proxy
export all_proxy=$proxy
export https_proxy=$proxy
git config --global http.proxy $proxy
git config --global https.proxy $proxy
git config --global url."https://".insteadOf git://
}
function unset_proxy() {
unset http_proxy
unset ftp_proxy
unset all_proxy
unset https_proxy
git config --global --unset http.proxy
git config --global --unset https.proxy
git config --global --unset url."https://".insteadOf
}
if [ "`networksetup -getcurrentlocation`" = "$switch_trigger_location" -a "`networksetup -getairportnetwork en0 | awk '{print $4}'`" = "$switch_trigger_network" ]; then
echo "Switch to proxy for office network"
set_proxy
else
echo "Unset proxy settings"
unset_proxy
fi