-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·92 lines (71 loc) · 1.29 KB
/
deploy.sh
File metadata and controls
executable file
·92 lines (71 loc) · 1.29 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
#!/bin/bash
deploy() {
echo -n "deploying $1 ... "
src=$HOME/$1
dest=$HOME/.dotfiles/$1
if [ -f $src ]; then
if [ ! $force ]; then
confirm-overwrite $src $dest
if [ $? == 1 ]; then
echo " skipping."
return 1
fi
fi
rm $src
fi
ln -s $dest $HOME/
echo " done!"
}
confirm-overwrite() {
src=$1
dest=$2
diff -q $src $dest > /dev/null
if [ $? != 0 ]; then
echo "files differ!"
echo " $src differs from $dest."
echo " Do you wish to continue? (y)es, (n)o, (v)iew diff"
read answer
if [ $answer == 'v' ]; then
diff $src $dest
echo "overwrite? [y/n]"
read really
if [ $really == 'n' ]; then
return 1
fi
elif [ $answer != 'y' ]; then
return 1
fi
fi
return 0
}
confirm() {
echo "This will overwrite existing dotfiles in your home directory."
echo "Are you sure you want to do this? [y/n]";
read answer
if [ $answer != "y" ]; then
echo "okay, bailing."
return 1;
fi
return 0;
}
while getopts ":y" opt; do
if [ $opt == "y" ]; then
force=1
fi
done
if [ ! $force ]; then
confirm
if [ $? == 1 ]; then
exit 1;
fi
fi
deploy .gitconfig
deploy .environment
deploy .bashrc
deploy .zshrc
deploy .aliases
deploy .functions
deploy .tmux.conf
echo "deploying ~/bin scripts"
mkdir -p $HOME/bin
ln -sf $HOME/.dotfiles/bin/* $HOME/bin