summaryrefslogtreecommitdiff
path: root/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'install.sh')
-rwxr-xr-xinstall.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..8870624
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,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