This repository has been archived by the owner on Sep 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·101 lines (76 loc) · 2.46 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
install_vimrc () {
set -e
set -u
echo -e "\033[32m➤ Installing! \033[0m"
command -v vim >/dev/null 2>&1 \
&& echo -e "\033[32m ✔ Found ❰ Vim ❱ \033[0m" \
|| {
echo -e "\033[31m ✘ Missing ❰ Vim ❱ \033[0m"
echo -e "\033[31m✘ Install failed!"
exit 1
}
command -v git >/dev/null 2>&1 \
&& echo -e "\033[32m ✔ Found ❰ Git ❱ \033[0m" \
|| {
echo -e "\033[31m ✘ Missing ❰ Git ❱ \033[0m"
echo -e "\033[31m✘ Install failed!"
exit 1
}
if [ -d $HOME/.vim ]; then
echo -e "\033[32m ✔ Exists ❰ ~/.vim ❱ \033[0m"
else
echo -e " ➤ Creating ❰ ~/.vim ❱ \033[0m"
mkdir -p $HOME/.vim
echo -e "\033[32m ✔ Created ❰ ~/.vim ❱ \033[0m"
fi
if [ -e $HOME/.vim/autoload/plug.vim ]; then
echo -e "\033[32m ✔ Found ❰ vim-plug ❱ \033[0m"
else
echo -e " ➤ Installing ❰ vim-plug ❱ \033[0m"
command -v git >/dev/null 2>&1 && \
env git clone https://github.com/junegunn/vim-plug $HOME/.vim/autoload >/dev/null 2>&1
echo -e "\033[32m ✔ Installed ❰ vim-plug ❱ \033[0m"
fi
if [ -f $HOME/.vimrc ] || [ -h $HOME/.vimrc ]; then
VIMRC_LINE=$(head -n 1 $HOME/.vimrc);
if [ "$VIMRC_LINE" != '" rxrc/vimrc' ]; then
echo -e " ➤ Exists ❰ ~/.vimrc ❱ \033[0m"
mv $HOME/.vimrc $HOME/.vimrc.preinstall
echo -e "\033[32m ✔ Moved to ❰ ~/.vimrc.preinstall ❱ \033[0m"
else
rm $HOME/.vimrc
fi
fi
echo -e " ➤ Installing ❰ ~/.vimrc ❱ \033[0m"
tee $HOME/.vimrc >/dev/null <<EOF
" rxrc/vimrc
" Disable powerline by default.
let g:powerline_loaded = 1
" Disable session autosave prompt.
let g:session_autosave = 'no'
" Skip initialization for vim-tiny or vim-small.
if !1 | finish | endif
call plug#begin(\$HOME . '/.vim/plugged')
if filereadable(\$HOME . '/.vim/plugged/vimrc/plugins.vim')
source \$HOME/.vim/plugged/vimrc/plugins.vim
if \$VIMRC_INSTALL == 'true'
PlugInstall
else
Plug 'rxrc/vimrc'
endif
else
Plug 'rxrc/vimrc', { 'on': [] }
PlugInstall
endif
call plug#end()
EOF
echo -e "\033[32m ✔ Installed ❰ ~/.vimrc ❱ \033[0m"
echo -e " ➤ Run ❰ PlugInstall ❱ \033[0m"
echo | vim -c qall!; \
(export VIMRC_INSTALL=true && echo | vim -c qall!); \
echo; \
echo -e "\033[32m ✔ Completed ❰ PlugInstall ❱ \033[0m"; \
echo -e "\033[32m✔ Install complete! \033[0m"; \
exit 0
}
install_vimrc