#!/usr/bin/env bash set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" source "$ROOT/lib.sh" need_cmd brew #────────────────────────────────────────────────────────────── # STATE: Preferred login shell (edit this value) #────────────────────────────────────────────────────────────── LOGIN_SHELL="bash" # Options: bash, zsh #────────────────────────────────────────────────────────────── # LOGIC: Idempotent shell configuration #────────────────────────────────────────────────────────────── # Resolve shell path case "$LOGIN_SHELL" in bash) shell_path="$(brew --prefix)/bin/bash" ;; zsh) shell_path="$(brew --prefix)/bin/zsh" ;; *) warn "Unknown shell: $LOGIN_SHELL" exit 1 ;; esac log "Ensuring login shell is $shell_path" # Check if shell is in /etc/shells if ! grep -qxF "$shell_path" /etc/shells; then log "Adding $shell_path to /etc/shells" echo "$shell_path" | sudo tee -a /etc/shells >/dev/null fi # Change shell if different if [[ "$SHELL" != "$shell_path" ]]; then log "Changing login shell to $shell_path" chsh -s "$shell_path" else log "Login shell already set to $shell_path" fi log "Login shell configured"