-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
executable file
·96 lines (74 loc) · 2.71 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
trap 'exit -2' INT
# shellcheck source=utils.sh
source ~/.config/yadm/utils.sh
OS_NAME=$(uname -s)
# A "full" bootstrap means to run everything. Otherwise just update vscode extension
# (and maybe fish completions)
: "${YADM_BOOTSTRAP_FULL:=0}"
function setup_macos() {
# Specify iTerm2 preferences directory
#shellcheck disable=SC2088
defaults write com.googlecode.iterm2.plist PrefsCustomFolder -string '~/.config/iterm2/'
defaults write com.googlecode.iterm2.plist LoadPrefsFromCustomFolder -bool true
defaults write com.hegenberg.BetterTouchTool BTTAutoLoadPath ~/.config/btt/Default.bttpreset
# Default file associations
duti ~/.config/duti
echo "macOS-specific setup is complete!"
}
function setup_linux() {
# TBD. Might need separate function each for NixOS / Termux
echo "Linux-specific setup is complete!"
}
function main() {
yadm submodule update --init
# Include "shared" git config in yadm repo
yadm enter git config --local include.path ~/.config/yadm/.gitconfig
# Ensure yadm alt SSH config files are set with the right permissions
chmod go-rw ~/.config/yadm/alt/.ssh/*
chmod go+r ~/.config/yadm/alt/.ssh/*.pub*
if [[ $YADM_BOOTSTRAP_FULL -eq 1 ]]; then
# For now, OS-specific bootstrap is part of "full". Might make sense
# to break them out separately in the future.
if [[ "$OS_NAME" == "Darwin" ]]; then
setup_macos
elif [[ "$OS_NAME" == "Linux" ]]; then
setup_linux
fi
# Install homebrew and use it to install basic packages/apps
if ! command -v brew &>/dev/null && \
confirm "'brew' command not found. Install it? "
then
eval "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
echo
fi
if ! brew bundle --global check && \
confirm "Install packages from Brewfile? "
then
brew bundle --global install
echo
fi
if confirm "Update fish auto-generated completions?"; then
fish -c 'fish_update_completions'
fi
if confirm "Install fisher plugins?"; then
fish -c 'set -gx fisher_path ~/.config/fish/fisher_install && fisher update'
fi
# Load GPG configuration for timeouts
gpgconf --reload gpg-agent
if confirm "Decrypt encrypted files?"; then
yadm git-crypt unlock
fi
fi
if ! check_vscode_exts &>/dev/null && \
confirm "Install VSCode extensions?"
then
install_vscode_exts
else
echo "VSCode extensions are up-to-date."
fi
}
main "$@"