-
Notifications
You must be signed in to change notification settings - Fork 21
/
debian_install.sh
executable file
·266 lines (225 loc) · 9.06 KB
/
debian_install.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/usr/bin/env bash
#-------------------------------------------------------------------------------
# function
#-------------------------------------------------------------------------------
function LOG() {
echo "[#Install Log] $1"
}
function ERROR() {
echo "[#Install Error] $1"
}
#-------------------------------------------------------------------------------
# get github release latest version number
# return value save to release_ver
# for example:
# getGithubLatestReleaseVersion "dandavison/delta" # release_ver=="v0.8.3"
# code from https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
#-------------------------------------------------------------------------------
function getGithubLatestReleaseVersion() {
release_ver=`curl --silent "https://api.github.com/repos/$1/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")'`
}
#-------------------------------------------------------------------------------
# get system arch
# return value save to sysarch
#-------------------------------------------------------------------------------
function getSysArch() {
sysarch=`uname -m`
}
# get system arch
getSysArch
#-------------------------------------------------------------------------------
# apt install
#-------------------------------------------------------------------------------
sudo apt update
LOG "apt install ..."
sudo apt install \
git vim zsh curl wget \
emacs tmux tldr python \
python3 python3-pip \
man gdb build-essential net-tools -y
LOG "apt install done"
#-------------------------------------------------------------------------------
# install oh my zsh
#-------------------------------------------------------------------------------
LOG "install zsh && oh-my-zsh ..."
if [ -d "$HOME/.oh-my-zsh" ]; then
LOG "oh my zsh already exists, reinstall it"
rm -rf "$HOME/.oh-my-zsh"
fi
if [ -f "$HOME/.zshrc" ]; then
LOG ".zshrc already exists, back up to .zshrc.bac"
mv "$HOME/.zshrc" "$HOME/.zshrc.bac"
fi
printf "y" | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# change zsh theme
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="bira"/' "$HOME/.zshrc"
chsh -s $(which zsh)
LOG "install zsh && oh-my-zsh done"
# zsh plugin
LOG "install zsh plugin ..."
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
sed -i 's/plugins=(/plugins=( zsh-autosuggestions /' "$HOME/.zshrc"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
sed -i 's/plugins=(/plugins=( zsh-syntax-highlighting /' "$HOME/.zshrc"
LOG "install zsh plugin done"
#-------------------------------------------------------------------------------
# git config
#-------------------------------------------------------------------------------
if [ -f "$HOME/.gitconfig" ]; then
LOG "git config file exists, back up to .gitconfig.bac"
mv "$HOME/.gitconfig" "$HOME/.gitconfig.bac"
fi
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.br branch
#-------------------------------------------------------------------------------
# custom script folder
#-------------------------------------------------------------------------------
LOG "create script folder ..."
if [ ! -d "$HOME/.rscripts" ]; then
mkdir "$HOME/.rscripts"
fi
echo export PATH='$PATH:$HOME/.rscripts' >> "$HOME/.zshrc"
LOG "create script folder done"
#-------------------------------------------------------------------------------
# tldr update
#-------------------------------------------------------------------------------
tldr --update
#-------------------------------------------------------------------------------
# emacs config
#-------------------------------------------------------------------------------
LOG "config emacs ..."
wget https://raw.githubusercontent.com/yangruihan/Notes/master/Emacs/config/__emacs2 -O ~/.emacs
if [ ! -d "$HOME/.emacs.d" ]; then
mkdir "$HOME/.emacs.d"
fi
wget https://raw.githubusercontent.com/yangruihan/Notes/master/Emacs/config/init11.el -O ~/.emacs.d/init.el
echo alias emsd=\'emacs --daemon\' >> "$HOME/.zshrc"
echo alias emsdq=\'emacsclient --eval \"\(kill-emacs\)\"\' >> "$HOME/.zshrc"
echo alias emc=\'emacsclient -t -a \"\"\' >> "$HOME/.zshrc"
wget https://raw.githubusercontent.com/yangruihan/Notes/master/Emacs/scripts/em.py -O ~/.rscripts/em.py
chmod +x ~/.rscripts/em.py
echo alias em=\'~/.rscripts/em.py\' >> "$HOME/.zshrc"
LOG "config emacs done"
#-------------------------------------------------------------------------------
# tmux config
#-------------------------------------------------------------------------------
LOG "config tmux ..."
if [ -f "$HOME/.tmux.conf" ]; then
LOG "tmux conf already exists, make a backup to .tmux.conf.bac"
mv "$HOME/.tmux.conf" "$HOME/.tmux.conf.bac"
fi
wget https://raw.githubusercontent.com/yangruihan/Notes/master/Backup/config/.tmux.conf -O ~/.tmux.conf
echo alias tmux=\"tmux -u\" >> "$HOME/.zshrc"
LOG "config tmux done"
#-------------------------------------------------------------------------------
# install delta
#-------------------------------------------------------------------------------
LOG "install delta ..."
getGithubLatestReleaseVersion "dandavison/delta"
delta_version=$release_ver
delta_arch="amd64"
if [ "$sysarch" = "x86_64" ]; then
delta_arch="amd64"
else
delta_arch="armhf"
fi
LOG "delta version $delta_version"
LOG "delta arch $delta_arch"
wget "https://github.com/dandavison/delta/releases/download/$delta_version/git-delta_${delta_version}_${delta_arch}.deb" -O delta.deb
sudo dpkg -i delta.deb
rm delta.deb
read -r -d '' delta_config << EOM
[pager]
diff = delta
log = delta
reflog = delta
show = delta
[delta]
features = side-by-side line-numbers decorations
syntax-theme = Dracula
plus-style = syntax "#003800"
minus-style = syntax "#3f0001"
[delta "decorations"]
commit-decoration-style = bold yellow box ul
file-style = bold yellow ul
file-decoration-style = none
hunk-header-decoration-style = cyan box ul
[delta "line-numbers"]
line-numbers-left-style = cyan
line-numbers-right-style = cyan
line-numbers-minus-style = 124
line-numbers-plus-style = 28
[interactive]
diffFilter = delta --color-only
EOM
echo "$delta_config" >> "$HOME/.gitconfig"
LOG "install delta done"
#-------------------------------------------------------------------------------
# install fd
#-------------------------------------------------------------------------------
LOG "install fd ..."
sudo apt install fd-find -y
echo alias fd=\"fd-find\" >> "$HOME/.zshrc"
LOG "install fd done"
#-------------------------------------------------------------------------------
# install ripgrep
#-------------------------------------------------------------------------------
LOG "install ripgrep ..."
sudo apt install ripgrep -y
LOG "install ripgrep done"
#-------------------------------------------------------------------------------
# install fzf
#-------------------------------------------------------------------------------
LOG "install fzf ..."
sudo apt install fzf -y
LOG "install fzf done"
#-------------------------------------------------------------------------------
# install mcfly
#-------------------------------------------------------------------------------
LOG "install mcfly ..."
getGithubLatestReleaseVersion "cantino/mcfly"
mcfly_version=$release_ver
mcfly_arch="x86_64-unknown-linux-musl"
if [ "$sysarch" = "x86_64" ]; then
mcfly_arch="x86_64-unknown-linux-musl"
else
mcfly_arch="armv7-unknown-linux-gnueabihf"
fi
LOG "mcfly version $mcfly_version"
LOG "mcfly arch $mcfly_arch"
wget "https://github.com/cantino/mcfly/releases/download/$mcfly_version/mcfly-${mcfly_version}-${mcfly_arch}.tar.gz" -O mcfly.tar.gz
tar xvf mcfly.tar.gz
mv mcfly "$HOME/.rscripts/"
rm mcfly.tar.gz
echo 'eval "$(mcfly init zsh)"' >> "$HOME/.zshrc"
LOG "install mcfly done"
#-------------------------------------------------------------------------------
# install autojump
#-------------------------------------------------------------------------------
LOG "install autojump ..."
sudo apt install autojump -y
echo ". /usr/share/autojump/autojump.sh" >> "$HOME/.zshrc"
LOG "install autojump done"
#-------------------------------------------------------------------------------
# install w3m
#-------------------------------------------------------------------------------
LOG "install w3m ..."
sudo apt install w3m -y
LOG "install w3m done"
#-------------------------------------------------------------------------------
# Install Finish
#-------------------------------------------------------------------------------
LOG "-------------------------------"
LOG "------- Install Finish --------"
LOG "-------------------------------"
#-------------------------------------------------------------------------------
# change to zsh
#-------------------------------------------------------------------------------
if [ ! -n "$ZSH_VERSION" ]; then
LOG "change to zsh"
zsh
else
source "$HOME/.zshrc"
fi