forked from Jackson-Qiu/BrewMyMac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brew_mirror.sh
executable file
·89 lines (73 loc) · 2.57 KB
/
brew_mirror.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
84
85
86
87
88
89
#! /bin/bash
###
# @Description :
# @Author : jsmjsm
# @Github : https://github.com/jsmjsm
# @Date : 2021-07-13 15:40:23
# @LastEditors : jsmjsm
# @LastEditTime : 2021-07-16 18:54:10
# @FilePath : /BrewMyMac/brew_mirror.sh
###
# > Change to diffrent Homebrew source
select_homebrew_mirror (){
flag=0;
while [ "$flag" != 1 ]
do
echo
echo " 请选择 Homebrew 镜像: "
echo " 默认选项:[1] Homebrew 官方源"
echo
echo " 1: Homebrew Default Mirror 官方源"
echo " 2: 清华大学 Tuna 源"
echo " 3: USTC 中科大源"
echo
read input
case $input in
1)
# echo "select_homebrew_mirror -> Debug: 1"
_change_homebrew_default
flag=1
;;
2)
# echo "select_homebrew_mirror -> Debug: 2"
_change_homebrew_tuna
flag=1
;;
3)
# echo "select_homebrew_mirror -> Debug: 3"
_change_homebrew_ustc
flag=1
;;
*)
_change_homebrew_default
# echo "select_homebrew_mirror -> Debug: default"
flag=1
;;
esac
done
exit 0
}
_change_homebrew_default (){
echo "Changing the homebrew mirror to: Deafult ..."
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
echo "Change Finifh! Run 'brew update' now... "
brew update
}
_change_homebrew_tuna (){
echo "Changing the homebrew mirror to: Tuna (清华大学 Tuna 源) ..."
echo "Reference from (参考): https://mirror.tuna.tsinghua.edu.cn/help/homebrew/ "
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
echo "Change Finifh! Run 'brew update' now... "
brew update
}
_change_homebrew_ustc (){
echo "Changing the homebrew mirror to: USTC (USTC 中科大源) ..."
echo "Reference from (参考): https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git "
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
echo "Change Finifh! Run 'brew update' now... "
brew update
}
select_homebrew_mirror