forked from jarv/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
30 lines (28 loc) · 722 Bytes
/
setup.sh
File metadata and controls
30 lines (28 loc) · 722 Bytes
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
#!/bin/bash
abspath () {
case "$1" in
/*)
printf "%s\n" "$1"
;;
*)
printf "%s\n" "$PWD/$1"
;; esac;
}
DIR=$(dirname $0)
DOTLINKS=$(find $DIR -maxdepth 1 -name "dotfile.*" -type f | grep -v "swp")
DOTDIRS=$(find $DIR -maxdepth 1 -name "dotfile.*.d" -type d)
LINKS="$DOTLINKS $DOTDIRS"
for file in $LINKS; do
link="$HOME/$(echo $(basename $file) | sed s/dotfile//)"
echo $link
if [[ -L "$link" ]];then
echo "skipping $file"
else
if [[ -r "$link" ]];then
echo "backing up ${link}"
mv $link{,.bak}
fi
echo "creating symlink $link"
ln -s $(abspath $file) $link
fi
done