forked from voku/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·122 lines (103 loc) · 2.88 KB
/
bootstrap.sh
File metadata and controls
executable file
·122 lines (103 loc) · 2.88 KB
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
120
121
122
#!/usr/bin/env bash
echo -e "${COLOR_GREEN}"
for z in {1..50}; do
for i in {1..16}; do
r="$(($RANDOM % 2))"
if [[ $(($RANDOM % 5)) == 1 ]]; then
if [[ $(($RANDOM % 4)) == 1 ]]; then
v+="\e[1m $r "
else
v+="\e[2m $r "
fi
else
v+=" "
fi
done
echo -e "$v"
v="";
done
echo " _ _ __ _ _"
echo " __| | ___ | |_ / _(_) | ___ ___"
echo " / _\` |/ _ \| __|____| |_| | |/ _ \/ __|"
echo " | (_| | (_) | ||_____| _| | | __/\__ \\"
echo " \__,_|\___/ \__| |_| |_|_|\___||___/"
echo ""
echo -e "${COLOR_NO_COLOUR}"
if [[ "$1" == "--force" ]] || [[ "$1" == "-f" ]]; then
FORCE=1
else
FORCE=0
fi
git pull origin master
doIt()
{
if [ ! -f ~/.config_dotfiles ]; then
cp .config_dotfiles_default ~/.config_dotfiles
fi
# copy dotfiles
git config --global -l | LANG=C sort > /tmp/oldgit$$
rsync --exclude-from .IGNORE -avhi --no-perms . ~/
source ~/.bash_profile
git config --global -l | LANG=C sort > /tmp/newgit$$
echo "git configuration not present anymore after bootstrapping:"
LANG=C comm -23 /tmp/oldgit$$ /tmp/newgit$$
echo -e "\nYou can use the following commands to add it again:"
LANG=C comm -23 /tmp/oldgit$$ /tmp/newgit$$ | while read line; do echo "git config --global --add "$(echo $line | sed 's/=/ \"/;s/$/\"/') ;done
# check for "force"
if [[ "$FORCE" == "1" ]]; then
return 0
fi
# try zsh?
read -p "Do you want to use the zsh-shell? (y/n) " -n 1 yesOrNo
echo
if [[ $yesOrNo =~ ^[Yy]$ ]]; then
sudo apt-get install zsh
chsh -s $(which zsh)
fi
#vim doesn't like ^M (CRLF) in .vim files. Make sure this will not happen on cygwin / windows systems
if [ "$(git config --system --get core.autocrlf)" == "true" ]; then
crlf_warning="--system "
fi
if [ "$(git config --global --get core.autocrlf)" == "true" ]; then
crlf_warning="${crlf_warning}--global"
fi
if [ -n "$crlf_warning" ]; then
echo "git config 'core.autocrlf' is currently true in '$crlf_warning'. Unset temporarly, otherwise VIM may have big problems!"
return 1
fi
# install vim-plugin-manager
if [ ! -d ~/.vim/bundle/vundle ]; then
mkdir ~/.vim/bundle
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
vim +BundleInstall +qall
else
read -p "Do you want to update vim-plugins? (y/n) " -n 1 yesOrNo
echo
if [[ $yesOrNo =~ ^[Yy]$ ]]; then
cd ~/.vim/bundle/vundle
git pull
vim +BundleUpdate +qall
fi
fi
}
dryRun()
{
rsync --exclude-from .IGNORE -avhni --no-perms . ~/
source ~/.bash_profile
}
if [[ "$FORCE" == "1" ]]; then
doIt
else
echo "Executing dry run..."
echo
dryRun
echo
echo
read -p "The files listed above will overwritten in your home directory. Are you sure you want to continue? (y/n) " -n 1 yesOrNo
echo
if [[ $yesOrNo =~ ^[Yy]$ ]]; then
doIt
fi
fi
unset -f doIt
unset -f dryRun