#!/usr/bin/env bash # macos-install.sh — Bootstrap Doom Emacs development environment on macOS # Run once on a fresh machine. Idempotent — safe to re-run. # Usage: bash scripts/macos-install.sh set -euo pipefail GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' info() { echo -e "${GREEN}▶${NC} $*"; } warn() { echo -e "${YELLOW}⚠${NC} $*"; } error() { echo -e "${RED}✗${NC} $*"; } section() { echo -e "\n${GREEN}══ $* ══${NC}"; } # ─── Homebrew ─────────────────────────────────────────────────────────────── section "Homebrew" if ! command -v brew &>/dev/null; then info "Installing Homebrew..." /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" else info "Homebrew already installed" fi # ─── Core GNU tools (Doom prefers GNU over BSD) ────────────────────────────── section "Core GNU tools" brew install --quiet \ coreutils \ gnu-sed \ findutils \ grep \ git \ curl \ wget \ jq # ─── Doom Emacs prerequisites ──────────────────────────────────────────────── section "Doom Emacs prerequisites" brew install --quiet \ cmake \ libtool \ automake \ autoconf \ pkg-config \ texinfo \ sqlite \ tree-sitter # ─── Emacs (if not already installed) ─────────────────────────────────────── section "Emacs" if ! command -v emacs &>/dev/null; then warn "Emacs not found. Install manually:" warn " brew install --cask emacs # pre-built GUI" warn " OR build from source with MacPorts/Homebrew for latest patches" else info "Emacs: $(emacs --version | head -1)" fi # ─── Search tools (Doom/Vertico/Consult use these) ─────────────────────────── section "Search & navigation tools" brew install --quiet \ fd \ ripgrep \ fzf \ bat \ the_silver_searcher # ─── Spell & grammar ───────────────────────────────────────────────────────── section "Spell & grammar" brew install --quiet \ ispell \ languagetool # ─── Email (mu4e + mbsync) ─────────────────────────────────────────────────── section "Email — mu4e" brew install --quiet \ mu \ isync # ─── PDF tools ─────────────────────────────────────────────────────────────── section "PDF tools" brew install --quiet \ poppler \ mupdf-tools # ─── Fonts (Doom uses nerd-fonts) ──────────────────────────────────────────── section "Fonts" brew install --quiet --cask \ font-jetbrains-mono-nerd-font \ font-fira-code-nerd-font \ 2>/dev/null || warn "Font casks may need manual install from nerd-fonts" # ─── Perl ──────────────────────────────────────────────────────────────────── section "Perl" brew install --quiet perl # Install cpanm if ! command -v cpanm &>/dev/null; then info "Installing cpanm..." curl -L https://cpanmin.us | perl - App::cpanminus fi info "Installing Perl modules (LSP, Tidy, Critic)..." cpanm --quiet --notest \ Perl::LanguageServer \ Perl::Tidy \ Perl::Critic \ App::perlimports \ 2>/dev/null || warn "Some Perl modules failed — run cpanm manually if needed" # ─── Python ────────────────────────────────────────────────────────────────── section "Python" brew install --quiet \ python \ pyenv \ ruff \ uv # Pyright LSP if ! command -v pyright &>/dev/null; then info "Installing pyright..." npm install -g pyright 2>/dev/null || warn "npm not found, install node first: brew install node" fi # ─── Go ────────────────────────────────────────────────────────────────────── section "Go" brew install --quiet go info "Installing Go tools..." go install golang.org/x/tools/gopls@latest 2>/dev/null || warn "gopls install failed" go install golang.org/x/tools/cmd/goimports@latest 2>/dev/null || warn "goimports install failed" go install github.com/go-delve/delve/cmd/dlv@latest 2>/dev/null || warn "delve install failed" # ─── Node.js (needed for some LSPs) ───────────────────────────────────────── section "Node.js" brew install --quiet node # ─── Ansible ───────────────────────────────────────────────────────────────── section "Ansible" brew install --quiet \ ansible \ ansible-lint # ─── Terraform ─────────────────────────────────────────────────────────────── section "Terraform" brew install --quiet \ terraform \ terraform-ls \ tflint # ─── Containers (Podman) ───────────────────────────────────────────────────── section "Podman / Containers" brew install --quiet \ podman \ hadolint # ─── Kubernetes ────────────────────────────────────────────────────────────── section "Kubernetes tools" brew install --quiet \ kubectl \ kubectx # ─── Version control extras ────────────────────────────────────────────────── section "Git extras" brew install --quiet \ git-delta \ gh # ─── perltidy config (if missing) ──────────────────────────────────────────── section "perltidy config" if [ ! -f "$HOME/.perltidyrc" ]; then info "Creating ~/.perltidyrc..." cat > "$HOME/.perltidyrc" << 'PERLTIDY' -l=100 -i=4 -ci=4 -ce -vt=0 -cti=0 -pt=0 -bt=0 -sbt=0 -bbt=0 -nsfs -nolq PERLTIDY fi # ─── Doom Emacs setup ──────────────────────────────────────────────────────── section "Doom Emacs" if [ ! -d "$HOME/.emacs.d" ]; then warn "Doom not installed. To install:" warn " git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.emacs.d" warn " ~/.emacs.d/bin/doom install" elif [ ! -d "$HOME/.doom.d" ]; then warn "~/.doom.d missing. Clone your config:" warn " git clone https://git.apps.sukany.cz/martin/emacs-doom ~/.doom.d" warn " git clone https://git.apps.sukany.cz/martin/emacs-org ~/org" warn " ~/.emacs.d/bin/doom sync" else info "Doom config found at ~/.doom.d" info "Run: ~/.emacs.d/bin/doom sync" fi # ─── Summary ───────────────────────────────────────────────────────────────── section "Done" echo "" echo "Manual steps remaining:" echo " 1. Create ~/.authinfo with CalDAV credentials" echo " machine cal.apps.sukany.cz login martin password YOUR_PASS" echo " 2. Configure mbsync: cp ~/.doom.d/examples/mbsyncrc ~/.mbsyncrc" echo " 3. If Emacs built from source: sudo port install texinfo tree-sitter" echo " 4. doom sync (in ~/.doom.d)" echo " 5. doom doctor (check for remaining issues)" echo "" info "Installation complete."