lib/weather.sh

308 B · 16 lines · bash

1#!/usr/bin/env bash
2
3brt_weather() {
4 local location="${*:-}"
5 brt_require curl
6
7 if [[ -z "$location" ]]; then
8 brt_info "Weather (auto-detect location):"
9 curl -fsSL "wttr.in?format=3"
10 else
11 brt_info "Weather for ${location}:"
12 curl -fsSL "wttr.in/${location// /+}?format=3"
13 fi
14 echo
15}
16