forked from tarmolov/configs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·115 lines (95 loc) · 2.97 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/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
# + .vim
clean() {
for file in .zshrc .tmux.conf .vimrc .profile .gitconfig
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 ;;
--clean)
echo "Clean old config files..."
clean
exit;;
-*)
echo "Illegal option"
;;
esac
;;
esac
done
echo "Config setup is started..."
echo
read -p "Config builder wants to delete .bashrc .zshrc, .tmux.conf, .gitconfig, .vimrc and .vim. Do you want to continue? (y/n)? " REPLY
[ "$REPLY" != "y" ] && exit
echo "Clean old config files..."
clean
if [ -d "$HOME/.dotfiles" ]; then
DOTFILES_FOLDER=".dotfiles"
elif [ -d "$HOME/dotfiles" ]; then
DOTFILES_FOLDER="dotfiles"
else
DOTFILES_FOLDER=${PWD##*/}
fi
# create symblinks
ln -sf ~/$DOTFILES_FOLDER/bashrc ~/.bashrc
ln -sf ~/$DOTFILES_FOLDER/tmux/.tmux.conf ~/.tmux.conf
ln -sf ~/$DOTFILES_FOLDER/vim/.vimrc ~/.vimrc
ln -sf ~/$DOTFILES_FOLDER/zsh/templates/.zshrc ~/.zshrc
ln -sf ~/$DOTFILES_FOLDER/.nvmrc ~/.nvmrc
cd ~/$DOTFILES_FOLDER
git submodule init
git submodule update
echo "Install vim plugins..."
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 "export DOTFILES_FOLDER=\"$DOTFILES_FOLDER\"" >> ~/.profile
echo ". ~/$DOTFILES_FOLDER/.profile" >> ~/.profile
echo "[include]" >> ~/.gitconfig
echo " path = $DOTFILES_FOLDER/.gitconfig" >> ~/.gitconfig
echo "Add useful commands"
mkdir -p ~/bin
ln -sf ~/$DOTFILES_FOLDER/.bin/diffconflicts ~/bin
echo "Add vscode settings"
mkdir -p "$HOME/Library/Application\ Support/Code/User"
cd "$HOME/Library/Application\ Support/Code/User"
ln -snf $HOME/.dotfiles/vscode/snippets ./
ln -snf $HOME/.dotfiles/vscode/keybindings.json ./
# add tmux start config
#ln -sf ~/$DOTFILES_FOLDER/.bin/tm ~/bin
echo
echo "Config setup is finished..."