-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap
executable file
·76 lines (65 loc) · 1.84 KB
/
bootstrap
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
#!/bin/sh
#
# Bootstrap a new macOS machine, installing dotfiles, software and configuring
# macOS defaults.
DOTFILES="${HOME}/.dotfiles"
assert_macos() {
if [ "$(uname -s)" != "Darwin" ]; then
echo "FATAL: macOS not detected, aborting bootstrap"
exit 1
fi
}
link_files() {
source="${DOTFILES}/${1}"
dest="${2}"
if [ -e "${dest}" ] && [ ! -h "${dest}" ]; then
echo " WARN: symlink failed, \"${dest}\" exists and is not a symlink"
elif [ -h "${dest}" ] && [ "$(readlink "${dest}")" != "${source}" ]; then
echo " WARN: symlink failed, \"${dest}\" is linked to another path"
elif [ ! -e "${dest}" ]; then
echo " INFO: symlink \"${source}\" to \"${dest}\""
ln -s "${source}" "${dest}"
fi
}
sync_dotfiles() {
echo " INFO: syncing dotfiles"
rsync \
--exclude ".DS_Store" \
--exclude ".git/" \
--exclude ".github/" \
--exclude "node_modules/" \
--archive \
--human-readable \
--no-perms \
. "${DOTFILES}";
link_files ".editorconfig" "${HOME}/.editorconfig"
link_files ".gitignore" "${HOME}/.gitignore"
link_files "git/.gitconfig" "${HOME}/.gitconfig"
link_files "zsh/.zshrc" "${HOME}/.zshrc"
link_files "vscode/settings.json" "${HOME}/Library/Application Support/Code/User/settings.json"
}
install_homebrew() {
if test ! "$(which brew)"; then
echo " INFO: installing Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
}
install_software() {
echo " INFO: installing software with Homebrew Bundle"
HOMEBREW_COLOR=1 brew bundle \
--file="macos/Brewfile" \
--quiet \
| sed -u '/^Using/d' \
| sed -u 's/^/ /'
}
assert_macos
sync_dotfiles
install_homebrew
install_software
source nodejs/install
source python/install
source zsh/install
if [ -z "${NO_MACOS}" ]; then
source macos/settings
fi
exit 0