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
|
#!/bin/bash
# Set up this account on a machine: the tools, checkouts and nvim plugins that
# the config link.sh links expects. Run it by hand, after `./link.sh yes`, once
# per machine and again whenever the Brewfile changes; every step only adds
# what is missing. Unlike link.sh it is slow and may stop to ask for a password,
# so nothing runs it on a timer.
#
# ~/src/soarez/dot/install.sh
#
# On a new Mac, also run ./macos-defaults.sh, once -- see its header. A private
# layer's bootstrap may call both for you.
#
# Runs under macOS's /bin/bash 3.2.
set -euo pipefail
dotfiles_dir="$(cd "$(dirname "$0")" && pwd)"
# 1. Homebrew packages, on macOS. Linux machines get their packages from
# whatever provisions them, not from here.
if [[ "$(uname)" == "Darwin" ]]; then
if ! command -v brew >/dev/null 2>&1; then
for b in /opt/homebrew/bin/brew /usr/local/bin/brew; do
if [[ -x "${b}" ]]; then
eval "$("${b}" shellenv)"
break
fi
done
fi
if ! command -v brew >/dev/null 2>&1; then
>&2 echo "ERROR: Homebrew is not installed. Install it first, then re-run this:"
>&2 echo ' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
exit 1
fi
# --no-upgrade: install what is missing and leave what is there alone. Plain
# `brew bundle` also upgrades every listed package that is out of date.
brew bundle --no-upgrade --file="${dotfiles_dir}/Brewfile"
fi
# 2. Checkouts the config reads: the pure prompt (config/zshrc falls back to a
# plain one without it) and the extra colour schemes bin/theme lists. Over
# https: both are public, so a fresh machine needs no ssh key for them.
# Existing checkouts are left alone.
clone() {
local url="$1" dest="$2"
if [[ -d "${dest}/.git" ]]; then
return
fi
mkdir -p "$(dirname "${dest}")"
git clone --quiet "${url}" "${dest}"
echo "cloned ${dest}"
}
clone https://github.com/sindresorhus/pure.git "${HOME}/src/sindresorhus/pure"
clone https://github.com/alacritty/alacritty-theme.git "${HOME}/src/alacritty/alacritty-theme"
# 3. nvim's plugins, so the first real launch does not stop to install them.
# `install`, not `sync`: install only fetches plugins that are missing, and
# leaves installed ones where this host's lock file (~/.config/nvim/
# lazy-lock.json, not in the repo) has them. sync would also update every
# plugin to its latest version and rewrite that lock file.
if command -v nvim >/dev/null 2>&1; then
nvim --headless "+Lazy! install" +qa || true
fi
if [[ "$(uname)" == "Darwin" ]]; then
echo
echo "Setting up a new Mac? Also run this, once:"
echo " ${dotfiles_dir}/macos-defaults.sh"
echo "It applies the baseline Finder, Dock and keyboard settings, and resets the Dock."
fi
|