#!/usr/bin/env bash # Weather backend: wttr.in with its native ANSI art (curl UA gets terminal colours). # Args: $1 = location (may be empty -> wttr.in geolocates the caller), $2 = query opts. # Prints the wttr.in body (ANSI or plain, per opts) to stdout. set -uo pipefail loc="${1:-}" opts="${2:-0}" # URL-encode spaces in a city name. loc="${loc// /+}" url="https://wttr.in/${loc}?${opts}" # -A curl makes wttr.in return terminal (ANSI) output regardless of the real UA. curl -sf -A curl --max-time 10 "$url"