-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·91 lines (75 loc) · 2.26 KB
/
build.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
#!/bin/sh
# Config builder
# Copyright 2012 Alexander Tarmolov <[email protected]>
# show program usage
show_usage() {
echo "usage: ./build.sh [--clean] --name=<your name> --email=<your email>"
echo " --clean removes all builded files (optional)"
echo " --name your name for git and debian"
echo " --email your email for git and debian"
exit
}
# clean config files
clean() {
for file in .bashrc .profile .gitconfig .screenrc .vimrc .vim
do
rm -rf ~/$file
done
}
# process command-line arguments
for OPT in "$@" ; do
case $OPT in
-*) true ;
case $OPT in
--help)
show_usage;;
--name=*)
NAME=${OPT##*=}
shift ;;
--email=*)
EMAIL=${OPT##*=}
shift ;;
-*)
echo "Illegal option"
;;
esac
;;
esac
done
echo "Config setup is started..."
echo
read -p "Config builder wants to delete .bashrc, .profile, .gitconfig, .screenrc, .vimrc and .vim. Do you want to continue? (y/n)? "
[ "$REPLY" != "y" ] && exit
echo "Clean old config files..."
clean
for file in .screenrc .vim .vimrc
do
echo "Set link to $file"
ln -sf ~/.config/tarmolov/$file ~/$file
done
echo "Install vim plugins..."
cd ~/.config/tarmolov
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
sleep 1
vim -c ":BundleInstall" -c ":qa"
cd - >> /dev/null
echo "Generate .profile and .gitconfig"
# generate .profile if name and e-mail are set
if [ -n "$NAME" ] && [ -n "$EMAIL" ]; then
echo "export DEBFULLNAME=\"$NAME\"" >> ~/.profile
echo "export DEBEMAIL=$EMAIL" >> ~/.profile
echo "export EMAIL=$EMAIL" >> ~/.profile
echo "[user]" >> ~/.gitconfig
echo " name = $NAME" >> ~/.gitconfig
echo " email = $EMAIL" >> ~/.gitconfig
fi
echo ". ~/.config/tarmolov/.profile" >> ~/.profile
echo "[include]" >> ~/.gitconfig
echo " path = .config/tarmolov/.gitconfig" >> ~/.gitconfig
echo "Add useful commands"
mkdir -p ~/bin
ln -sf ~/.config/tarmolov/.bin/diffconflicts ~/bin
# screen doesn't read .profile
ln -sf ~/.profile ~/.bashrc
echo
echo "Config setup is finished..."