forked from BlackIkeEagle/vimfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·53 lines (46 loc) · 1.06 KB
/
install
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
#!/bin/bash
# defaults
gvimrc=0
clean=0
authorname=""
authoremail=""
# usage
function usage() {
echo "use: $0 [options]"
echo " -a author name (required)"
echo " -e author email (required)"
echo " -g also install gvimrc"
echo " -c do clean installation"
echo " -h show this usage"
exit 0
}
# process options
while getopts ":a:e:gch" arg; do
case "$arg" in
a) authorname="$OPTARG" ;;
e) authoremail="$OPTARG" ;;
g) gvimrc=1 ;;
c) clean=1 ;;
h) usage ;;
esac
done
if [ "$authorname" = "" ] || [ "$authoremail" = "" ]; then
echo "author name and author email are required"
echo ""
usage
fi
# clean current vim stuff
if [ $clean -ne 0 ]; then
rm -f ~/.gvimrc
rm -f ~/.vimrc
rm -rf ~/.vim
fi
# copy new vimrc
cp -a ./vimrc ~/.vimrc
# set authorname and authoremail in vimrc
sed -e "s#\(.*AuthorName=\).*#\1\"$authorname\"#" -e "s#\(.*AuthorEmail=\).*#\1\"$authoremail\"#" -i ~/.vimrc
# copy gvimrc when requested
[ $gvimrc -eq 1 ] && cp -a ./gvimrc ~/.gvimrc
# put the vimfiles in place
[ ! -d ~/.vim ] && mkdir ~/.vim
cp -a ./vimfiles/* ~/.vim/