-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy.sh
83 lines (72 loc) · 1.88 KB
/
proxy.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function setProxies {
# NPM
npm config set proxy $proxy
npm config set https-proxy $proxy
if [ -f "$HOME/.zshrc" ]; then
echo "export ALL_PROXY=\"$proxy\"" >> ~/.zshrc
sed -i '/unset HTTP_PROXY/d' ~/.zshrc
sed -i '/unset http_proxy/d' ~/.zshrc
sed -i '/unset ALL_PROXY/d' ~/.zshrc
echo "Added to ~/.zshrc"
else
echo "export ALL_PROXY=\"$proxy\"" >> ~/.bashrc
sed -i '/unset HTTP_PROXY/d' ~/.bashrc
sed -i '/unset http_proxy/d' ~/.bashrc
sed -i '/unset ALL_PROXY/d' ~/.bashrc
echo "Added to ~/.bashrc"
fi
# Git
git config --global http.proxy $proxy
}
function unsetProxies {
# NPM
npm config delete proxy
npm config delete https-proxy
# Ruby
if [ -f "$HOME/.zshrc" ]; then
sed -i '/export ALL_PROXY/d' ~/.zshrc
echo "unset HTTP_PROXY" >> ~/.zshrc
echo "unset http_proxy" >> ~/.zshrc
echo "unset ALL_proxy" >> ~/.zshrc
echo "Removed From ~/.zshrc"
else
sed -i '/export ALL_PROXY/d' ~/.bashrc
echo "unset HTTP_PROXY" >> ~/.bashrc
echo "unset http_proxy" >> ~/.bashrc
echo "unset ALL_proxy" >> ~/.bashrc
echo "Removed From ~/.bashrc"
fi
# Git
git config --unset --global http.proxy
}
function options {
echo -n "Enter your Proxy URL (example: proxy.ccsd.net) > "
read url
echo -n "Enter your port number (example: 80) > "
read port
proxy="http://$url:$port"
echo "You entered: $proxy"
read -p "Is this correct? (y/n)" choice
case "$choice" in
y|Y ) setProxies;;
n|N ) options;;
* ) echo "invalid";;
esac
}
PS3='What would you like to do?'
options=("Set Proxies" "Unset Proxies" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Set Proxies")
options; break
;;
"Unset Proxies")
unsetProxies; break
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done