e4b3b0360ecc
add tty/NO_COLOR-gated ANSI palette to install.sh (pink prefix, cyan paths/commands, green ✓, dim dividers, red errors) mirroring nina's binary; colorize say/die/hr, the system-wide install section, the config-import prompt + success, and the farewell; add a blank line before the manual block so it no longer mashes against the [y/N] answer
- time
- 2026-06-05 16:43 UTC · 4 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- color the install output
- parent
- f31363a24350
↓ nina-e4b3b036.tar.gzatlas at this save
files changed1 file
install.sh+40 −24install.sh+40 −24
@@ -10,6 +10,21 @@1010 INSTALL_DIR="${NINA_INSTALL_DIR:-$HOME/.local/bin}"1111 MIN_ZIG_MINOR=161212 13+# Color, but only when stdout is a real terminal and NO_COLOR is unset. Under14+# `curl … | sh` stdin is the pipe yet stdout is still the tty, so -t 1 holds.15+# Palette mirrors nina's own: pink prefix, cyan for paths/commands.16+if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then17+ PINK="$(printf '\033[38;2;255;183;197m')"18+ CYAN="$(printf '\033[36m')"19+ GREEN="$(printf '\033[32m')"20+ RED="$(printf '\033[31m')"21+ DIM="$(printf '\033[2m')"22+ BOLD="$(printf '\033[1m')"23+ RESET="$(printf '\033[0m')"24+else25+ PINK=""; CYAN=""; GREEN=""; RED=""; DIM=""; BOLD=""; RESET=""26+fi27+1328 os="$(uname -s)"1429 arch="$(uname -m)"1530 case "${os}-${arch}" in@@ -23,15 +38,15 @@2338 esac2439 2540 have() { command -v "$1" >/dev/null 2>&1; }26-say() { printf 'nina: %s\n' "$1"; }27-die() { say "error: $1" >&2; exit 1; }41+say() { printf '%snina:%s %s\n' "$PINK" "$RESET" "$1"; }42+die() { printf '%snina:%s %serror:%s %s\n' "$PINK" "$RESET" "$RED" "$RESET" "$1" >&2; exit 1; }2843 blank() { printf '\n'; }2944 is_nixos() { [ -e /etc/NIXOS ]; }3045 3146 # Unprefixed output for the closing sections, where the "nina:" stutter on3247 # every line hurts readability. `out` indents body text; `hr` draws a divider.33-out() { printf ' %s\n' "$1"; }34-hr() { printf ' ────────────────────────────────────────────────\n'; }48+out() { printf ' %s\n' "$1"; }49+hr() { printf ' %s────────────────────────────────────────────────%s\n' "$DIM" "$RESET"; }3550 3651 fetch_text() {3752 if have curl; then curl -fsSL "$1"@@ -205,8 +220,8 @@205220 206221 # Already wired up — just remind how to apply it.207222 if grep -qF "$nina_nix" "$config" 2>/dev/null; then208- out "Already imported in ${config}."209- out "Apply with: sudo nixos-rebuild switch"223+ out "already imported in ${CYAN}${config}${RESET}"224+ out "apply with ${BOLD}sudo nixos-rebuild switch${RESET}"210225 blank211226 return 0212227 fi@@ -217,7 +232,7 @@217232 218233 # Read the answer from the terminal so it works under `curl … | sh`.219234 [ -r /dev/tty ] || return 1220- printf ' add this import to %s now? [y/N] ' "$config" > /dev/tty235+ printf ' add it to %s%s%s now? %s[y/N]%s ' "$CYAN" "$config" "$RESET" "$DIM" "$RESET" > /dev/tty221236 IFS= read -r ans < /dev/tty 2>/dev/null || ans=""222237 case "$ans" in223238 [Yy]*) ;;@@ -247,9 +262,9 @@247262 rm -f "$tmp"248263 249264 blank250- out "✓ added the import to ${config}"251- out " backup kept at ${backup}"252- out " apply with sudo nixos-rebuild switch"265+ out "${GREEN}✓${RESET} added the import to ${CYAN}${config}${RESET}"266+ out " ${DIM}backup kept at ${backup}${RESET}"267+ out " apply with ${BOLD}sudo nixos-rebuild switch${RESET}"253268 blank254269 return 0255270 }@@ -285,26 +300,27 @@285300 286301 blank287302 hr288- out "system-wide install (optional)"303+ out "${BOLD}system-wide install${RESET} ${DIM}(optional)${RESET}"289304 hr290305 blank291- out "nina is installed for your user. To manage her with the rest of"292- out "your system, a NixOS module has been written to:"306+ out "nina is installed for your user. To manage her alongside the"307+ out "rest of your system, a module was written to:"293308 blank294- out " ${nina_nix}"309+ out " ${CYAN}${nina_nix}${RESET}"295310 blank296311 297312 if offer_config_import "/etc/nixos/configuration.nix" "$nina_nix"; then298313 return 0299314 fi300315 301- out "To enable it yourself, add this line to /etc/nixos/configuration.nix"302- out "(inside the existing imports = [ … ]; list):"303316 blank304- out " ${nina_nix}"317+ out "to do it yourself, add this to the ${CYAN}imports${RESET} list in"318+ out "${CYAN}/etc/nixos/configuration.nix${RESET}:"305319 blank306- out "then run: sudo nixos-rebuild switch"320+ out " ${CYAN}${nina_nix}${RESET}"307321 blank322+ out "then run ${BOLD}sudo nixos-rebuild switch${RESET}"323+ blank308324 }309325 310326 # ── Zig version check ─────────────────────────────────────────────────────────@@ -414,12 +430,12 @@414430 # ── closing message ──────────────────────────────────────────────────────────415431 416432 farewell() {417- printf '\n'418- printf ' thank you!! running nina update occasionally will keep me in tip top shape.\n'419- printf ' get started by running nina hello\n'420- printf '\n'421- printf ' if nina turns out not to be for you, nina goodbye will remove her cleanly.\n'422- printf '\n'433+ blank434+ printf ' %sthank you!!%s get started by running %snina hello%s\n' "$PINK" "$RESET" "$CYAN" "$RESET"435+ printf ' run %snina update%s occasionally to keep me in tip-top shape\n' "$CYAN" "$RESET"436+ blank437+ printf ' %snot for you?%s %snina goodbye%s %sremoves her cleanly%s\n' "$DIM" "$RESET" "$CYAN" "$RESET" "$DIM" "$RESET"438+ blank423439 }424440 425441 # ── main ──────────────────────────────────────────────────────────────────────