-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.sh
executable file
·99 lines (76 loc) · 2.65 KB
/
config.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
#Check Internet connection
if ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then
echo "Downloading data..."
else
echo "Please check your internet connection and try again."
exit
fi
function progress {
bar=''
for (( x=0; x <= $1; x++ )); do
sleep 0.05
bar="${bar} "
echo -ne "\r"
echo -ne "\e[43m$bar\e[0m"
local left="$(( 100 - $x ))"
printf " %${left}s"
echo -n "${x}%"
done
echo -ne "\r \r"
}
progress 30
function installer() {
#Set some vim option in ~/.vimrc
set_option=('set hlsearch' 'syntax on' 'set background=dark' 'colorscheme hybrid_material' 'set number' 'set mouse=a' 'set titlestring=%t' 'set title' 'set ruler' 'set confirm' 'set spell')
len_set_option=${#set_option[@]}+1
function setter() {
for ((i = 1; i < len_set_option; i++)); do
echo "${set_option[i]}" >>~/.vimrc
done
}
config_file=~/.vimrc
if [[ -f "$config_file" ]]; then
rm ~/.vimrc
touch ~/.vimrc
setter
else
touch ~/.vimrc
setter
fi
progress 50
#Install 'The NERDTree' plugin, vim-hybrid-material and dependency
#https://github.com/preservim/nerdtree
#https://github.com/kristijanhusak/vim-hybrid-material
mkdir -p ~/.vim/autoload ~/.vim/bundle &&
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
vim_bundle_path=~/.vim/bundle/vim-sensible/
if [ -d "$vim_bundle_path" ]; then rm -Rf $vim_bundle_path; fi
progress 60
cd ~/.vim/bundle &&
git clone https://github.com/tpope/vim-sensible.git >/dev/null 2>&1
nerdtree_path=~/.vim/bundle/nerdtree
if [ -d "$nerdtree_path" ]; then rm -Rf $nerdtree_path; fi
progress 70
git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree >/dev/null 2>&1
nerdtree_command_list=('execute pathogen#infect()' 'call pathogen#infect()' 'filetype plugin indent on' 'nnoremap <leader>n :NERDTreeFocus<CR>' 'nnoremap <C-n> :NERDTree<CR>' 'nnoremap <C-t> :NERDTreeToggle<CR>' 'nnoremap <C-f> :NERDTreeFind<CR>' 'autocmd VimEnter * NERDTree | wincmd p')
len_nerdtree_command_list=${#nerdtree_command_list[@]}+1
for ((j = 1; j < len_nerdtree_command_list; j++)); do
echo "${nerdtree_command_list[j]}" >>~/.vimrc
done
progress 80
git clone https://github.com/kristijanhusak/vim-hybrid-material ~/.vim/bundle/vim-hybrid-material >/dev/null 2>&1
cp -r ~/.vim/bundle/vim-hybrid-material/colors/ ~/.vim/colors/ >/dev/null 2>&1
progress 94
function set_plugin() {
vim -c ':Helptags' 1>/dev/null 2>/dev/null
}
set_plugin &
mySelfID=$!
kill $mySelfID >/dev/null 2>&1
}
selfID=$!
installer
kill $selfID >/dev/null 2>&1
progress 100
echo " Finished :) "
exit