-
Notifications
You must be signed in to change notification settings - Fork 1
/
dotify.sh
executable file
·78 lines (63 loc) · 2.07 KB
/
dotify.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
#!/bin/bash
# Bash deploy script from Johan Bleuzen
# Inspired by Rakefile from Zach Holman : https://github.com/holman/dotfiles/blob/master/Rakefile
skip_all=false
overwrite_all=false
backup_all=false
function link {
for file in `find ~/.dotfiles -name "*.symlink" -path "*/\.*"`; do
filename=$(basename $file)
filename=~/.${filename%.*}
overwrite=false
backup=false
if [ -e $filename ] || [ -h $filename ]; then
if [ $skip_all == "false" ] && [ $overwrite_all == "false" ] && [ $backup_all == "false" ]; then
echo "File already exists: $filename, what do you want to do? [s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all"
read ACTION
case $ACTION in
O) overwrite_all=true;;
o) overwrite=true;;
B) backup_all=true;;
b) backup=true;;
S) skip_all=true;;
s) continue;;
esac
fi
if [ $overwrite_all == "true" ] || [ $overwrite == "true" ]; then
rm -rf $filename
fi
if [ $backup_all == "true" ] || [ $backup == "true" ]; then
mv $filename ${filename}.backup
fi
fi
# TODO : Add a filter for OSX folder
ln -s $file $filename 2> /dev/null
done
# Install config folders
for file in `find ~/.dotfiles -name "*.config"`; do
filename=$(basename $file)
[[ ! -L ~/.config/"${filename%.*}" ]] && ln -s ~/.dotfiles/$filename ~/.config/${filename%.*}
done
}
function unlink {
for file in `find ~/.dotfiles -name "*.symlink" | grep -v '\.git'`; do
filename=$(basename $file)
filename=~/.${filename%.*}
if [ -h $filename ]; then
rm -rf $filename
fi
if [ -e ${filename}.backup ]; then
mv ${filename}.backup $filename
fi
done
}
if [ "$1" == "unlink" ] || [ "$1" == "uninstall" ]; then
unlink
exit
fi
# Terminal mode
if [ "$1" == "-t" ]; then
overwrite_all=true
fi
link
exit 0