-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·219 lines (174 loc) · 5.02 KB
/
run.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/bin/sh
set -e
hide_dock_automatically() {
/usr/bin/osascript - <<'EOF'
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.dock"
end tell
tell application "System Events" to tell process "System Preferences"
tell window "Dock"
set theCheckbox to checkbox "自动显示和隐藏 Dock" —- Automatically hide and show the Dock
tell theCheckbox
set checkboxStatus to value of theCheckbox as boolean
if not checkboxStatus then click theCheckbox
end tell
end tell
end tell
delay 0.5
tell application "System Preferences" to quit
EOF
}
install_xcode_cmdline_tools() {
xcode-select --install
read -n 1 -p 'Press [Enter] when install complate.'
}
install_oh_my_zsh() {
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
}
install_zimfw() {
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
}
setup_shell() {
brew install zsh
brew install zsh-autosuggestions
cat <<'EOF' >> ~/.zshrc
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
EOF
brew install starship
cat <<'EOF' >> ~/.zshrc
eval "$(starship init zsh)"
EOF
mkdir -p ~/.config && touch ~/.config/starship.toml
brew tap homebrew/cask-fonts
brew install font-fira-code-nerd-font
}
setup_homebrew() {
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" && brew update
}
bundle_homebrew() {
brew bundle --file="./Brewfile"
}
prepare_folders() {
mkdir -p ~/code/github
mkdir -p ~/code/github-self
}
config_git() {
cat <<'EOF' > ~/.gitconfig
[user]
name = ld000
email = [email protected]
[core]
editor = vim
EOF
}
config_vim() {
mkdir -p ~/.vim ~/.vim/autoload ~/.vim/backup ~/.vim/colors ~/.vim/plugged
# touch ~/.vimrc
copy ./.vimrc ~/.vimrc
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
}
setup_java() {
cat <<'EOF' >> ~/.zshrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
EOF
}
setup_go() {
download_url=https://dl.google.com/go/go1.13.3.darwin-amd64.pkg
pkg_file=${download_url##*/}
curl -LO $download_url
sudo installer -pkg $pkg_file -target /
rm $pkg_file
cat <<'EOF' >> ~/.zshrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GO111MODULE=auto
export GOPROXY=https://goproxy.cn
EOF
cat <<'EOF' >> ~/.bash_profile
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GO111MODULE=auto
export GOPROXY=https://goproxy.cn
EOF
source ~/.bash_profile
mkdir -p $GOPATH
}
setup_js() {
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
echo '' >> ~/.zshrc
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.zshrc
echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> ~/.zshrc
source ~/.bash_profile
nvm install 4
nvm install 6
nvm install 8
npm install --global yrm --registry=https://registry.npm.taobao.org
yrm use cnpm
npm i -g yarn
}
setup_ssh() {
ssh-keygen -C [email protected]
cat ~/.ssh/id_rsa.pub
}
show_hide_file() {
defaults write com.apple.Finder AppleShowAllFiles YES;KillAll Finder
}
setup_maven() {
download_url=https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.tar.gz
tar_file=${download_url##*/}
curl -LO $download_url
tar xzvf ./apache-maven-3.6.2-bin.tar.gz
mv apache-maven-3.6.2 ~/depend/
rm -rf apache-maven-3.6.2-bin.tar.gz
cat <<'EOF' >> ~/.zshrc
export MAVEN_PATH=$HOME/depend/apache-maven-3.6.2
export PATH=$PATH:$MAVEN_PATH/bin
EOF
}
setup_font() {
brew tap homebrew/cask-fonts
brew install font-fira-code
}
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\\n$fmt\\n" "$@"
}
# run function
hide_dock_automatically
show_hide_file
install_xcode_cmdline_tools
prepare_folders
setup_homebrew
bundle_homebrew
# install_oh_my_zsh
# install_zimfw
setup_shell
# mysql should start on launch
# ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
setup_go
# setup_js
config_git
config_vim
setup_java
setup_maven
setup_ssh
# setup_font
# Hold my own hand to make sure I finish configuring.
echo "Don't forget that you need to:
1. Add your ssh keys (you put them in your secret hiding place)."
read -n 1 -p 'Press [Enter] when you have added your ssh key.'
echo "2. source ~/.zshrc"
read -n 1 -p 'Press [Enter] when you have execute the command.'
echo "3. vim :PluginInstall"
read -n 1 -p 'Press [Enter] when you have execute the command.'
echo "4. iterm2: Preferences>Profiles>Text>Non-ASCII Font is the same as your main Font(fira code)"
read -n 1 -p 'Press [Enter] when you have execute the command.'