-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsetup.sh
executable file
·92 lines (81 loc) · 2.49 KB
/
setup.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
90
91
92
#!/bin/sh
osType=$(uname -s)
[ "$(whoami)" = "root" ] || sudo=sudo
# 在Mac OSX上安装HomeBrew
installHomeBrewIfNeeded() {
if command -v brew > /dev/null ; then
brew update
else
printf "\n\n" | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
}
# 安装额外的一些扩展支持
installBashCompletionExt() {
if [ "$osType" = "Darwin" ] ; then
str=/usr/local/etc/bash_completion.d
else
str=/etc/bash_completion.d
fi
cd "$str" || exit 1
$sudo curl -LO https://raw.github.com/git/git/master/contrib/completion/git-completion.bash
}
writeEnv() {
if [ "$osType" = "Darwin" ] ; then
str=/usr/local/etc/bash_completion
else
str=/usr/share/bash-completion/bash_completion
fi
$sudo printf "%s\n" "[ -f $str ] && . $str" >> /etc/profile
}
main() {
if [ "$osType" = "Darwin" ] ; then
installHomeBrewIfNeeded &&
brew install curl bash-completion &&
writeEnv &&
installBashCompletionExt
elif [ "$osType" = "Linux" ] ; then
command -v apt-get > /dev/null && {
$sudo apt-get -y update &&
$sudo apt-get -y install curl bash-completion &&
writeEnv &&
installBashCompletionExt
exit $?
}
command -v dnf > /dev/null && {
$sudo dnf -y update &&
$sudo dnf -y install curl bash-completion &&
writeEnv &&
installBashCompletionExt
exit $?
}
command -v yum > /dev/null && {
$sudo yum -y update &&
$sudo yum -y install curl bash-completion &&
writeEnv &&
installBashCompletionExt
exit $?
}
command -v zypper > /dev/null && {
$sudo zypper update -y &&
$sudo zypper install -y curl bash-completion &&
writeEnv &&
installBashCompletionExt
exit $?
}
command -v pacman > /dev/null && {
$sudo pacman -Syyuu --noconfirm &&
$sudo zypper -S --noconfirm curl bash-completion &&
writeEnv &&
installBashCompletionExt
exit $?
}
command -v apk > /dev/null && {
$sudo apk update &&
$sudo apk add curl bash-completion &&
writeEnv &&
installBashCompletionExt
exit $?
}
fi
}
main