-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·89 lines (77 loc) · 2.21 KB
/
install
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
#!/usr/bin/env bash
NOLINK=0
uname -s | grep MINGW &>/dev/null && NOLINK=1
LINK='ln -s'
[ $NOLINK -ne 0 ] && LINK='cp -a'
etc="$HOME/etc"
if [ ! -d "$etc" ]; then
echo ERROR: Configuration directory $etc not found - exiting.
exit 1
fi
echo Updating dotfile links in $HOME from $etc
map="
bash_profile:.bash_profile
bashrc:.bashrc
dosemurc:.dosemurc
fonts.conf:.config/fontconfig/fonts.conf
gdbinit:.gdbinit
gitconfig:.gitconfig
gtk.css:.config/gtk-3.0/gtk.css
gtk-settings.ini:.config/gtk-3.0/settings.ini
hgrc:.hgrc
inputrc:.inputrc
lldbinit:.lldbinit
minttyrc:.minttyrc
plan:.plan
screenrc:.screenrc
startxwinrc:.startxwinrc
tmux.conf:.tmux.conf
user-dirs.dirs:.config/user-dirs.dirs
vimrc:.vimrc
Xmodmap:.Xmodmap
Xresources:.Xresources
"
for f in $map; do
src="$etc/$(echo "$f" | cut -d: -f1)"
dst="$HOME/$(echo "$f" | cut -d: -f2)"
if [ ! -f "$src" ]; then
echo ERROR: Missing source file $src - exiting.
exit 1
fi
dstdir=$(dirname "$dst")
if [ "x$dstdir" != "x." -a ! -d "$dstdir" ]; then
mkdir -p "$dstdir"
if [ $? -ne 0 ]; then
echo "ERROR: failed to make $dstdir"
exit 1
fi
fi
if [ -f "$dst" -a ! -L "$dst" ]; then
if [ $NOLINK -ne 0 ]; then
dstdiff="$dst.diff"
diff -Naur "$dst" "$src" > $dstdiff
if [ $? -ne 0 ]; then
echo WARNING: $dst differs from $src - please merge
echo
cat "$dst.diff"
echo
fi
else
dstbak="$dst.bak"
echo WARNING: Destination file $dst already exists and is not a link - moving it out of the way to $dstbak.
mv "$dst" "$dstbak"
fi
fi
if [ -L "$dst" ]; then
cursrc=$(readlink -f "$dst")
if [ "$cursrc" != "$src" ]; then
dstbak="$dst.bak"
echo WARNING: Destination file $dst already exists and is a link to $cursrc - moving it out of the way to $dstbak.
mv "$dst" "$dstbak"
fi
fi
if [ ! -f "$dst" ]; then
echo Installing $src as $dst
$LINK "$src" "$dst"
fi
done