How to get Weather on the Mac Console

Here is a simple way to get the weather from the console.

$ weather Pieniezno
Weather for City: Pieniezno, Poland

  _`/"".-.     Moderate or heavy rain shower
   ,\_(   ).   20 °C          
    /(___(__)  ↑ 7 km/h       
    ‚‘‚‘‚‘‚‘   7 km           
    ‚’‚’‚’‚’   2.7 mm         
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ Fri 29. Jul ├───────────────────────┬──────────────────────────────┐
│           Morning            │             Noon      └──────┬──────┘    Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│    \  /       Partly Cloudy  │  _`/"".-.     Light rain sho…│  _`/"".-.     Moderate or he…│  _`/"".-.     Patchy rain ne…│
│  _ /"".-.     25 – 27 °C     │   ,\_(   ).   27 – 28 °C     │   ,\_(   ).   20 °C          │   ,\_(   ).   17 °C          │
│    \_(   ).   ↖ 8 – 9 km/h   │    /(___(__)  ↑ 9 – 11 km/h  │    /(___(__)  ↑ 7 – 15 km/h  │    /(___(__)  ↑ 9 – 20 km/h  │
│    /(___(__)  10 km          │      ‘ ‘ ‘ ‘  10 km          │    ‚‘‚‘‚‘‚‘   7 km           │      ‘ ‘ ‘ ‘  9 km           │
│               0.0 mm | 3%    │     ‘ ‘ ‘ ‘   0.9 mm | 98%   │    ‚’‚’‚’‚’   2.7 mm | 96%   │     ‘ ‘ ‘ ‘   1.6 mm | 95%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ Sat 30. Jul ├───────────────────────┬──────────────────────────────┐
│           Morning            │             Noon      └──────┬──────┘    Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│     \   /     Sunny          │  _`/"".-.     Patchy rain ne…│  _`/"".-.     Patchy rain ne…│  _`/"".-.     Patchy rain ne…│
│      .-.      21 – 22 °C     │   ,\_(   ).   22 – 23 °C     │   ,\_(   ).   20 °C          │   ,\_(   ).   16 °C          │
│   ― (   ) ―   ↗ 16 – 19 km/h │    /(___(__)  ↗ 18 – 22 km/h │    /(___(__)  → 6 – 13 km/h  │    /(___(__)  ↗ 9 – 19 km/h  │
│      `-’      10 km          │      ‘ ‘ ‘ ‘  9 km           │      ‘ ‘ ‘ ‘  9 km           │      ‘ ‘ ‘ ‘  9 km           │
│     /   \     0.1 mm | 16%   │     ‘ ‘ ‘ ‘   0.6 mm | 90%   │     ‘ ‘ ‘ ‘   0.6 mm | 88%   │     ‘ ‘ ‘ ‘   0.2 mm | 46%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ Sun 31. Jul ├───────────────────────┬──────────────────────────────┐
│           Morning            │             Noon      └──────┬──────┘    Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│  _`/"".-.     Light rain sho…│  _`/"".-.     Patchy rain ne…│  _`/"".-.     Patchy rain ne…│  _`/"".-.     Patchy rain ne…│
│   ,\_(   ).   23 – 25 °C     │   ,\_(   ).   21 – 22 °C     │   ,\_(   ).   20 – 21 °C     │   ,\_(   ).   17 – 18 °C     │
│    /(___(__)  → 15 – 18 km/h │    /(___(__)  ↘ 9 – 11 km/h  │    /(___(__)  ← 5 km/h       │    /(___(__)  ↑ 3 – 5 km/h   │
│      ‘ ‘ ‘ ‘  10 km          │      ‘ ‘ ‘ ‘  9 km           │      ‘ ‘ ‘ ‘  9 km           │      ‘ ‘ ‘ ‘  9 km           │
│     ‘ ‘ ‘ ‘   0.6 mm | 81%   │     ‘ ‘ ‘ ‘   0.5 mm | 81%   │     ‘ ‘ ‘ ‘   1.1 mm | 79%   │     ‘ ‘ ‘ ‘   0.4 mm | 71%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘

For this we need a very simple shell script:

#!/bin/bash

if [ "$1" == "" ]; then
  curl wttr.in/$(LocateMe -f "{LAT}+{LON}")
else
  curl wttr.in/$1
fi

If you don’t pass a parameter, it uses LocateMe which you’d have to download separately. LocateMe makes available the current location of the computer on the command line.

Share