forked from gmonfort/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·41 lines (30 loc) · 840 Bytes
/
setup.sh
File metadata and controls
executable file
·41 lines (30 loc) · 840 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
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
[[ -z "$BACKUP_FILES" ]] && BACKUP_FILES=1
if [ ! -z "$1" ]; then
HOME="$1"
fi
echo "Using HOME: $HOME"
echo "BACKUP_FILES: $BACKUP_FILES"
# make symlinks to $HOME
# ensure we're on the base of the dotfiles repo
toplevel="$(git rev-parse --show-toplevel)" || (echo "Not in git directory" && exit 1)
echo "symlinking ..."
cd "$toplevel" && for f in $(ls -A); do
[[ $f = .git ]] && continue
[[ $f =~ ^[^.] ]] && continue # only dot files
local target=$HOME/$f
if [[ -f $target || -L $target || -d $target ]]; then
if [ ! -z "$BACKUP_FILES" ]; then
mv $HOME/"$f"{,.bak}
else
# recursive in case of a directory
rm -rf "$HOME/$f"
fi
fi
echo "Symlinking $toplevel/$f to $HOME/$f ..."
ln -s "$toplevel/$f" $HOME/"$f"
# if [[ -d $target ]]; then
# else
# fi
done
exit 0