-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
119 lines (101 loc) · 3.27 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
#!/bin/bash
# Print Onesimos logo.
cat << "EOF"
.-://:-. `:`
.+syyyyyyyys+. :ooo/`
/yyyyyyyyyyyyyy+``/oooo/`
+yys+++++oooooooy+ /ooooo/````````````..
`yyy/...``````...sy. .ooooo/...```````..`
`yyyyss+``````sssyy. .oooooo++:`````..`
+yyyyy+``````syyy+ :ooooo+:.````..`
`+yyyy+``````syy+` -oooo+:.````.:+/.
.+sy+``````o+. `:ooo+:.````.:+ooo+/.
`::.``.:``````-`./+oo+:.````.:+ooooooo+/.
-+ooo+/::``````++ooo+:.````.:+ooooooooooo+/.
`-+ooooo/``````+oo+:.````.:+oooooooooooooo+/`
`-+ooo/``````++:.````.:+oooooooooooooo+:.
`-+o/``````-.````.:+oooooooooooooo+:`
`-:``````````.:+oooooooooooooo+-`
-````````.:+oooooooooooooo/-`
-``````.:+oooooooooooooo/.
-````.:+ooooooooooooo+:`
-``..``-+oooooooooo+:`
-..` `-+oooooo+-`
-` -+oo/.
-.
EOF
echo "------------------------"
echo "Welcome. You're going to install the amazing Onesimos Vim configuration!"
echo "------------------------"
# Checking for git and vim
echo -e "\nChecking the required environment..."
if [[ -x "$(command -v vim)" && -x "$(command -v git)" ]]; then
echo "Done."
else
echo "Please check if you have vim and git installed."
exit
fi
# Ask for alternative root directory
echo -e "\nInstall in the home directory?"
while true; do
read -n 1 -p "(<Enter> to confirm)" key
# if empty (Enter)
if [[ -z "$key" ]]; then
VIMRCDIR="$HOME"
# else ask for a path
else
echo ""
read -p "Enter an alternative path: " VIMRCDIR
VIMRCDIR=${VIMRCDIR/#\~/$HOME} # replace tilde with $HOME
fi
if [ -d "${VIMRCDIR}" ]; then
echo -e "\nThe vimrc path is going to be $VIMRCDIR"
break
else
echo -e "The given directory doesn't exist.\nCreate?"
select yn in Yes No; do
case $yn in
Yes ) mkdir "$VIMRCDIR";break;break;;
No ) echo "Restarting...";break;;
esac
done
fi
done
# Cloning Repo from GitHub
cd $VIMRCDIR || exit
MYVIMRC="${VIMRCDIR%/}/vimrc"
echo -e "\nCloning the repository on GitHub..."
git clone https://github.com/BaksiLi/Onesimos ./vimrc && echo "Done." || (cd $MYVIMRC && git pull)
# Install Onesimos Functions
# Once they are ready...
# Checking old .vimrc file
echo -e "\nChecking old .vimrc file..."
if test -f ".vimrc"; then
echo "Found!"
_oldrc="$HOME/.vimrc"
_newrc="$MYVIMRC/vimrc.backup"
echo "Moving it to $MYVIMRC/vimrc.backup"
mv "$_oldrc" "$_newrc"
fi
echo "Done."
# Create new .vimrc file
echo -e "\nCreating new .vimrc"
touch "$HOME/.vimrc"
cat >> "$HOME/.vimrc" << EOL
"return" 2>&- || "exit"
let \$VIMRCDIR = '$MYVIMRC'
let \$MYVIMDOT = \$VIMRCDIR.'/init.vim'
if filereadable(glob(\$MYVIMDOT))
source \$MYVIMDOT
else
echomsg 'Vim configuration folder not found!'
endif
EOL
[ -f "$HOME/.vimrc" ] && echo "Done." || exit
# TODO: verification
echo ""
read -n 1 -s -r -p "Installation Complete!"
# if echo $EDITOR not vim, ask
# export EDITOR=vim
echo -e "\nLaunching Vim..."
vim -c "PlugInstall"