-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·169 lines (148 loc) · 5.59 KB
/
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
#!/bin/bash
msg() {
printf '%b\n' "$1" >&2
}
success() {
msg "\33[32m[✔]\33[0m ${1}${2}"
}
error() {
msg "\33[31m[✘]\33[0m ${1}${2}"
}
program_exists() {
local ret='0'
command -v $1 >/dev/null 2>&1 || { local ret='1'; }
# fail on non-zero return value
if [ "$ret" -ne 0 ]; then
return 1
fi
return 0
}
program_must_exist() {
program_exists $1
# throw error on non-zero return value
if [ "$?" -ne 0 ]; then
error "You must have '$1' installed to continue."
fi
}
msg ">>> Start checking basic requirement..."
program_must_exist "nvim"
program_must_exist "git"
program_must_exist "zsh"
program_must_exist "tmux"
success "Done."
# PS3='Please choose which version to be installed: '
# options=("basic python version(without YouCompleteMe)" "python & C++ version(with YCM)" "python & frontend version(with YCM)" "full version")
# select opt in "${options[@]}"
# do
# case "$REPLY" in
# 1)
# echo "let g:cfg_bundle_preset = 'nano'" >> .vimrc.before
# break
# ;;
# 2)
# echo "let g:cfg_bundle_preset = 'cpp'" >> .vimrc.before
# break
# ;;
# 3)
# echo "let g:cfg_bundle_preset = 'frontend'" >> .vimrc.before
# break
# ;;
# 4)
# echo "let g:cfg_bundle_preset = 'full'" >> .vimrc.before
# break
# ;;
# *) echo "invalid option";;
# esac
# done
# vim
#msg "[vim] Config vim..."
#msg "[vim] Install Plug for vim plugins management..."
#git clone --depth=1 https://github.com/junegunn/vim-plug.git $PWD/vim-plug
#mkdir -p ~/.vim/autoload
#cp $PWD/vim-plug/plug.vim ~/.vim/autoload/plug.vim
#rm -rf $PWD/vim-plug
##curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim >/dev/null 2>&1
#mv ~/.vimrc ~/.vimrc.bkp > /dev/null 2>&1
#mv ~/.vimrc.before ~/.vimrc.before.bkp > /dev/null 2>&1
#mv ~/.vimrc.bundles ~/.vimrc.bundles.bkp > /dev/null 2>&1
#ln -s $PWD/.vimrc ~/.vimrc
#ln -s $PWD/.vimrc.before ~/.vimrc.before
#ln -s $PWD/.vimrc.bundles ~/.vimrc.bundles
#vim -u "$PWD/.vimrc.bundles" "+set nomore" "+PlugInstall!" "+PlugClean" "+qall"
# zsh
msg "[zsh] Config zsh..."
msg "[zsh] Install oh-my-zsh..."
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
mv ~/.zshrc ~/.zshrc.bkp >/dev/null 2>&1
ln -sf $PWD/.zshrc ~/.zshrc
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
msg "[zsh] Prepare to change shell to zsh."
# If this platform provides a "chsh" command (not Cygwin), do it, man!
if hash chsh >/dev/null 2>&1; then
flag_chsh=1
msg "[zsh] Do you want to change your default shell to zsh? (password is needed) [y/n]"
read opt
case $opt in
y*|Y*|"") msg "[zsh] Changing the shell..." ;;
n*|N*) msg "[zsh] Shell change skipped."; flag_chsh=0 ;;
*) msg "[zsh] Invalid choice. Shell change skipped."; flag_chsh=0 ;;
esac
if [ "$flag_chsh" != 0 ]; then
if ! chsh $USER -s $(grep /zsh$ /etc/shells | tail -1); then
error "[zsh] chsh command unsuccessful. Change your default shell manually."
else
export SHELL="$zsh"
success "[zsh] Done. You may need to re-login or reopen terminal to see the effect"
fi
else
msg "[zsh] You can use 'chsh -s /bin/zsh' to set it as default manually."
fi
# Else, suggest the user do so manually.
else
error"[zsh] Cannot find chsh command!"
fi
fi
# nvim
msg "[nvim] Config nvim..."
msg "[nvim] Install Packer for nvim plugins management..."
if [[ ! -d ~/.local/share/nvim/site/pack/packer/start/packer.nvim ]]; then
git clone --depth=1 https://github.com/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/start/packer.nvim
fi
mkdir -p ~/.config
mv ~/.config/nvim ~/.config/nvim.bkp >/dev/null 2>&1
ln -sf $PWD/nvim ~/.config/
nvim -u "$PWD/init.before.vim" --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
success "[nvim] Done."
# eslint
#mv ~/.eslintrc.js ~/.eslintrc.js.bkp >/dev/null 2>&1
#ln -s $PWD/.eslintrc.js ~/.eslintrc.js
# ternjs
#mv ~/.tern-config ~/.tern-config.bkp >/dev/null 2>&1
#ln -s $PWD/.tern-config ~/.tern-config
# pylint
#mv ~/.pylintrc ~/.pylintrc.bkp >/dev/null 2>&1
#ln -s $PWD/.pylintrc ~/.pylintrc
# yapf
#mv ~/.style.yapf ~/.style.yapf.bkp >/dev/null 2>&1
#ln -s $PWD/.style.yapf ~/.style.yapf
# gdbinit
mv ~/.gdbinit ~/.gdbinit.bkp >/dev/null 2>&1
ln -sf $PWD/.gdbinit ~/.gdbinit
# tmux
msg "[tmux] Config tmux..."
mkdir -p ~/.tmux/plugins
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
git clone https://github.com/tmux-plugins/tmux-sensible ~/.tmux/plugins/tmux-sensible
git clone https://github.com/tmux-plugins/tmux-resurrect ~/.tmux/plugins/tmux-resurrect
git clone https://github.com/beeryardtech/tmux-net-speed.git ~/.tmux/plugins/tmux-net-speed
git clone https://github.com/samoshkin/tmux-plugin-sysstat.git ~/.tmux/plugins/tmux-plugin-sysstat
mv ~/.tmux.conf ~/.tmux.conf.bkp >/dev/null 2>&1
ln -sf $PWD/.tmux.conf ~/.tmux.conf
success "[tmux] Done."
msg "\nThanks for using my dotfiles."
msg "© `date +%Y` https://github.com/dc3671/dotfiles"
exec zsh -l