-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·71 lines (56 loc) · 1.39 KB
/
setup.sh
File metadata and controls
executable file
·71 lines (56 loc) · 1.39 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
#!/bin/bash
#
# This script sets up symlinks inside the user's $HOME directory. It provides overwrite protection.
basename=$(basename $0)
# sanity checking
if [[ ! -f .git/config ]]; then
echo "Run $basename from the root of the quantum repo"
exit 1
fi
if [[ $1 == "--force" ]]; then
force=true
shift
fi
# what files to skip
skips=(. ..)
# make a breadcrumb trail
repo=$(pwd)
# go to our home directory
pushd $HOME 2>&1 >> /dev/null
# symlink all files
# TODO - forcing directories doesn't work
for i in $(ls -a $repo/home); do
# skip certain files
if [[ "$i" == "." || "$i" == ".." ]]; then
continue
fi
# already symlinked
if [[ -L $i ]]; then
echo "already symlinked: $i"
fi
# condition: force
if [[ $force ]]; then
echo "forcing symlink: $i"
rm $i
ln -sf $repo/home/$i ./$i
continue
# condition: file doesn't exist
elif [[ ! -e $i ]]; then
echo "symlinking: $i"
ln -s $repo/home/$i ./$i
# condition: file or symlink already exists. prompt.
else
read -p "file (or symlink exists): $i. overwrite? (y/n)"
if [[ "$REPLY" == "y" ]]; then
echo "backing up $i to $i.original"
cp -r $i $i.original
rsync -av ./$i ./$i.original
echo "symlinking: $i"
ln -sf $repo/home/$i ./$i
fi
fi
done
popd 2>&1 >> /dev/null
# activate git submodules
git submodule init
git submodule update