generated from spenserblack/dotfiles-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·44 lines (40 loc) · 911 Bytes
/
bootstrap.sh
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
#!/bin/sh
SCRIPT_PATH="$(readlink -f $0)"
DOTFILES="$(dirname "$SCRIPT_PATH")"
FORCE="false"
LNARGS="-s"
while [ $# -gt 0 ]; do
case "$1" in
-f|--force)
FORCE="true"
LNARGS="$LNARGS -f"
;;
*)
echo "Unknown option: $1" >&2
exit 1
;;
esac
shift
done
create_symlinks() {
DOTFILES_PATH="$1"
for FILENAME in $(find "$DOTFILES_PATH" -type f); do
# SNOTE: kip .gitkeep file
if [ "$(basename "$FILENAME")" = ".gitkeep" ]; then
continue
fi
DEST="$HOME/${FILENAME#$DOTFILES_PATH/}"
DESTDIR="$(dirname "$DEST")"
mkdir -p "$DESTDIR"
# NOTE: If the file exists, skip creating a conflicting symlink
if [ -e "$DEST" ] && [ "$FORCE" != "true" ]; then
echo "$DEST exists: skipping $FILENAME" >&2
continue
fi
ln $LNARGS "$FILENAME" "$DEST"
echo "Linked: $FILENAME"
done
}
create_symlinks "$DOTFILES/.all"
create_symlinks "$DOTFILES/.linux"
echo "Bootstrap complete"