Repository navigation
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·62 lines (53 loc) · 1.88 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·62 lines (53 loc) · 1.88 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
#! /usr/bin/env zsh
set -euo pipefail
# Determine Absolute Working Path
REPOSITORY_ROOT=$(git rev-parse --show-toplevel)
# Request Sudo Upfront
sudo -v
while true; do sudo -n -v || exit; sleep 60; kill -0 "$$" || exit; done 2> /dev/null &
sudo_keepalive_pid=$!
cleanup_sudo_keepalive() {
kill "$sudo_keepalive_pid" 2>/dev/null || true
}
stop_bootstrap() {
local exit_status=$1
cleanup_sudo_keepalive
exit "$exit_status"
}
trap cleanup_sudo_keepalive EXIT
trap 'stop_bootstrap 130' INT
trap 'stop_bootstrap 143' TERM
# Set Login Shell to Zsh
current_shell=$(dscl . -read ~/ UserShell 2>/dev/null | awk '{print $2}')
if [ "$current_shell" != "/bin/zsh" ]; then
sudo chsh -s /bin/zsh "$USER"
fi
# Symlink Git Configuration
if [ ! -L "${HOME}/.gitconfig" ]; then
ln -fs "${REPOSITORY_ROOT}/.gitconfig" "${HOME}/.gitconfig"
fi
# Personalize Git Configuration (written to ~/.gitconfig.local, never committed)
LOCAL_GITCONFIG="${HOME}/.gitconfig.local"
if [ ! -f "${LOCAL_GITCONFIG}" ]; then
touch "${LOCAL_GITCONFIG}"
git config --file "${LOCAL_GITCONFIG}" core.excludesfile "${REPOSITORY_ROOT}/.gitignore"
echo -n "Commit Author: " && read -r author
git config --file "${LOCAL_GITCONFIG}" user.name "$author"
echo -n "Commit Email: " && read -r email
git config --file "${LOCAL_GITCONFIG}" user.email "$email"
fi
# System Preferences
source "${REPOSITORY_ROOT}/system/macos.sh"
source "${REPOSITORY_ROOT}/system/terminal.sh"
# Configure Dock on First Run Only
DOCK_SENTINEL="${HOME}/.config/bento/.dock-configured"
if [ ! -f "${DOCK_SENTINEL}" ]; then
source "${REPOSITORY_ROOT}/system/dock.sh"
mkdir -p "$(dirname "${DOCK_SENTINEL}")"
touch "${DOCK_SENTINEL}"
fi
source "${REPOSITORY_ROOT}/system/finder.sh"
# Run Setup Scripts
source "${REPOSITORY_ROOT}/system/homebrew.sh"
source "${REPOSITORY_ROOT}/system/fonts.sh"
source "${REPOSITORY_ROOT}/shell/install.sh"