-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·94 lines (76 loc) · 1.84 KB
/
bootstrap.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
#!/bin/bash
# Get the dir of the current script
script_dir="$( cd "$( dirname "$0" )" && pwd )"
# Keep a log of all created links (used by revert.sh)
loglink() {
if ! grep -q -s "$1" $script_dir/.log; then
echo "$1" >> $script_dir/.log
fi
}
# Count created links
counter=0
dolink() {
ln -s "$origin" "$dest"
loglink "$dest"
counter=$(($counter + 1))
}
checklink() {
# Force link creation
if [ $force = 1 ]; then
# If exists and is not a symlink
if [ -e $dest ] && [ ! -h $dest ]; then
if [ ! -e $dest.backup ]; then
# Backup original file
mv $dest $dest.backup
else
echo "Error! $dest.backup already exists."
fi
fi
if [ ! -e $dest ]; then
dolink
fi
else
if [ ! -e $dest ]; then
dolink
fi
fi
}
symlinkhome() {
for f in $script_dir/home/*; do
origin=$f
dest="$HOME/.`basename $f`"
checklink
done
}
symlink() {
if [ $1 ] && [ $2 ]; then
origin="$script_dir/others/$1"
dest=$2
checklink
fi
}
force=0
# Check if script was called with `-f` flag
if [ $1 ]; then
if [ $1 = "-f" ]; then
force=1
fi
fi
###############################################################################
symlinkhome
symlink "redshift.conf" "$HOME/.config/redshift.conf"
mkdir -p ~/.local/share/radiotray
symlink "radiotray.xml" "$HOME/.local/share/radiotray/bookmarks.xml"
mkdir -p ~/.oh-my-zsh/themes
symlink "viszu.zsh-theme" "$HOME/.oh-my-zsh/themes/viszu.zsh-theme"
###############################################################################
mkdir -p ~/.vim/bundle
git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
if [ -e ~/.vimrc ]; then
sudo vim +PlugUpdate +PlugClean +PlugUpgrade +qall
fi
if [ $counter = 1 ]; then
echo "Done! $counter symlink created."
else
echo "Done! $counter symlinks created."
fi