Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·90 lines (87 loc) · 3.45 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·90 lines (87 loc) · 3.45 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
#!/bin/sh
for file in $(ls -A | grep -vE '\.git$|\.gitignore$|\.sh$|README.md$|\.DS_Store$|\.config$'); do
target=${HOME}/${file}
if [ -e $target ]; then
if [ -L $target ]; then
resolved=$(readlink -f $target)
if [ "$resolved" != "$(readlink -f $file)" ]; then
echo -n "$target already exists. Do you want to overwrite it? [y/N]: "
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
unlink $target
ln -sf $(readlink -f $file) $target
echo "[symbolic link] $target -> $(readlink -f $file)"
fi
fi
else
echo "$target already exists. Do you want to overwrite it? (y/N)"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
mv $target ${target}.bak
ln -sf $(readlink -f $file) $target
echo "[symbolic link] $target -> $(readlink -f $file)"
fi
fi
else
rm -rf $target
ln -s $(readlink -f $file) $target
echo "[symbolic link] $target -> $(readlink -f $file)"
fi
done
for file in $(find .config -maxdepth 1 -mindepth 1 | grep -vE '\.DS\_Store$'); do
target=${HOME}/${file}
if [ -f $target ] || [ -d $target ]; then
if [ -L $target ]; then
resolved=$(readlink -f $target)
if [ "$resolved" != "$(readlink -f $file)" ]; then
echo -n "$target already exists. Do you want to overwrite it? [y/N]: "
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
unlink $file
ln -sf $(readlink -f $file) $target
echo "[symbolic link] $target -> $(readlink -f $file)"
fi
fi
else
echo -n "$target already exists. Do you want to overwrite it? [y/N]: "
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
mv $target ${target}.bak
ln -sf $(readlink -f $file) $target
echo "[symbolic link] $target -> $(readlink -f $file)"
fi
fi
else
ln -s $(readlink -f $file) $target
echo "[symbolic link] $target -> $(readlink -f $file)"
fi
done
# for latex
for file in $(find .config/latex -maxdepth 1 -mindepth 1 | grep -vE '\.DS\_Store$'); do
target=${HOME}/$(basename "$file")
if [ -f $target ] || [ -d $target ]; then
if [ -L $target ]; then
resolved=$(readlink -f $target)
if [ "$resolved" != "$(readlink -f $file)" ]; then
echo -n "$target already exists. Do you want to overwrite it? [y/N]: "
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
unlink $file
ln -sf $(readlink -f $file) $target
echo "[symbolic link] $target -> $(readlink -f $file)"
fi
fi
else
echo -n "$target already exists. Do you want to overwrite it? [y/N]: "
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
mv $target ${target}.bak
ln -sf $(readlink -f $file) $target
echo "[symbolic link] $target -> $(readlink -f $file)"
fi
fi
else
ln -s $(readlink -f $file) $target
echo "[symbolic link] $target -> $(readlink -f $file)"
fi
done