#!/bin/bash set -euo pipefail DOTFILES_DIR="$(cd "$(dirname "$0")/.." && pwd)" SETUP_DIR="$DOTFILES_DIR/setup" # =========================================================================== # Symlinks # =========================================================================== "$SETUP_DIR/symlinks" # =========================================================================== # Shell # =========================================================================== echo "" echo "Setting up shell..." FISH_PATH=$(command -v fish) if [ -n "$FISH_PATH" ]; then grep -Fxq "$FISH_PATH" /etc/shells || echo "$FISH_PATH" | sudo tee -a /etc/shells [ "$SHELL" != "$FISH_PATH" ] && chsh -s "$FISH_PATH" fi mkdir -p ~/.ssh && chmod 700 ~/.ssh mkdir -p ~/repos # =========================================================================== # Packages # =========================================================================== echo "" if [ "$(uname)" = "Darwin" ]; then echo "Installing Homebrew packages..." # Homebrew 6+ refuses to load formulae from non-official taps until they're # trusted. Trust the taps the Brewfile declares so `brew bundle` doesn't fail. grep -oE '^tap "[^"]+"' "$DOTFILES_DIR/Brewfile" \ | sed -E 's/^tap "([^"]+)"/\1/' \ | while read -r tap; do brew trust --tap "$tap"; done brew bundle --file="$DOTFILES_DIR/Brewfile" fi # =========================================================================== # Plugins (git submodules) # =========================================================================== echo "" echo "Initialising submodules..." git -C "$DOTFILES_DIR" submodule update --init --recursive command -v bat >/dev/null && bat cache --build command -v nvim >/dev/null && nvim --headless "+Lazy! sync" +qa # =========================================================================== # App icons # =========================================================================== if [ "$(uname)" = "Darwin" ]; then echo "" echo "Applying app icons..." "$SETUP_DIR/icons-apply" fi # =========================================================================== # macOS defaults # =========================================================================== if [ "$(uname)" = "Darwin" ]; then echo "" echo "Applying macOS defaults..." macos-defaults apply "$SETUP_DIR/macos-defaults.d/" # Show the ~/Library folder chflags nohidden ~/Library # Reveal IP, hostname, OS version etc. when clicking the clock in the login window. # /Library/Preferences requires root, so this only runs when not already set. if [ "$(defaults read /Library/Preferences/com.apple.loginwindow AdminHostInfo 2>/dev/null)" != "HostName" ]; then sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName fi # Timezone — symlinking /etc/localtime requires root, so only when not already set. if [ "$(readlink /etc/localtime)" != "/var/db/timezone/zoneinfo/Europe/Amsterdam" ]; then sudo ln -sf /var/db/timezone/zoneinfo/Europe/Amsterdam /etc/localtime fi fi echo "" echo "Done."