
Lukas - https://unsplash.com/photos/a-computer-screen-with-a-lot-of-data-on-it-MU8w72PzRow
Using the wttr.in service, you can get weather forecasts on your terminal. The following Perl script (weather.pl) displays the forecast for the next three days:
#!/usr/bin/perl # weather.pl --- # # Filename: weather.pl # Description:Weather on command line using wttr.in # Author: Francisco Yepes Barrera # Maintainer:Francisco Yepes Barrera # Created: Mon Oct 7 02:09:46 2024 (+0200) # Version: 1.0 # Package-Requires: (strict) # Last-Updated: Fri Aug 1 14:08:04 2025 (+0200) # By: Francisco Yepes Barrera # Update #: 20 # URL: https://www.godelia.org # Keywords: weather forecasting, moon phase, perl # # # Commentary: # # Weather on command line using wttr.in # For comments write an email to <paco.yepes@godelia.org> # # # Change Log: # # # # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. # # # Code: use strict; if (@ARGV > 1 or !@ARGV) { print "Usage: weather.pl [ location ]\n"; print "location examples: Madrid, madrid\n"; print "'moon' as location for lunar phase\n"; exit; } # Examples: Madrid, madrid # 'moon' as argument for lunar phase system("curl wttr.in/$ARGV[0]"); # # weather.pl ends here
Run without arguments, the script returns the syntax for execution:
Usage: weather.pl [ location ] location examples: Madrid, madrid 'moon' as location for lunar phase
The program accepts a single argument, which can be the name of a place, the postcode, or the keyword moon. For example:

The moon argument prints the moon phase to the terminal:

The following script (weather-moon.pl) does a little more than weather.pl:
#!/usr/bin/perl # weather-moon.pl --- # # Filename: weather-moon.pl # Description: Weather + moon phase in command line using wttr.in # Author: Francisco Yepes Barrera # Maintainer: Francisco Yepes Barrera # Created: Mon Oct 7 09:40:12 2024 (+0200) # Version: 1.0 # Package-Requires: (strict, POSIX) # Last-Updated: Fri Aug 1 14:37:06 2025 (+0200) # By: Francisco Yepes Barrera # Update #: 128 # URL: https://www.godelia.org # Keywords: weather forecasting, moon phase, perl # # # Commentary: # # Weather + moon phase in command line using wttr.in # For comments write an email to <paco.yepes@godelia.org> # # # Change Log: # # # # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. # # # Code: use strict; use POSIX qw(strftime); if (@ARGV != 1) { print "Usage: weather.pl [ location ]\n"; print "location examples: Madrid, madrid\n"; print "'moon' as location for lunar phase\n"; exit; } $ARGV[0] = lc($ARGV[0]); `~/sh-scripts/weather.pl $ARGV[0] > /tmp/weather-location 2>/dev/null`; `echo > /tmp/weather-moon; echo >> /tmp/weather-moon; echo >> /tmp/weather-moon; echo >> /tmp/weather-moon; echo >> /tmp/weather-moon; echo >> /tmp/weather-moon; echo >> /tmp/weather-moon; echo >> /tmp/weather-moon; echo >> /tmp/weather-moon; ~/sh-scripts/weather.pl moon >> /tmp/weather-moon 2>/dev/null`; `sed -i 's/Follow .*\@igor_chubin.* for wttr.in updates//g' /tmp/weather-location`; `sed -i '\$d' /tmp/weather-location`; `sed -i 's/Follow .*\@igor_chubin.* for wttr.in updates//g' /tmp/weather-moon`; `sed -i '\$d' /tmp/weather-moon`; if ($ARGV[0] eq "moon") { # Idea found in https://github.com/desertplant/moon-phase-background # In the script, the author update the background image with the moon # phase downloaded as image from Nasa web my $d1 = int(strftime("%j", gmtime)); my $d2 = int(strftime("%H", gmtime)); my $str = sprintf("%04d", $d1 * 24 - 23 + $d2); my $im = "moon.$str.tif"; # Big image # my $url = "https://svs.gsfc.nasa.gov/vis/a000000/a005400/a005415/frames/5760x3240_16x9_30p/plain/$im"; # Medium image my $url = "https://svs.gsfc.nasa.gov/vis/a000000/a005400/a005415/frames/3840x2160_16x9_30p/plain/$im"; `wget -O /tmp/$im $url`; system("chafa -c full --color-space din99d --work 9 --align left --scale max --font-ratio 0.38 --optimize 9 '/tmp/$im'"); } else { system("paste /tmp/weather-location /tmp/weather-moon"); } # # weather-moon.pl ends here
The syntax is the same as for weather.pl. The script allows you to simultaneously display the weather forecast for the next three days and the lunar phase:

If the moon argument is specified, weather-moon.pl does not generate an ASCII drawing of the moon phase but downloads the image for the current day from the NASA website (thanks to Christopher Canty for his work and the idea). The script requires the chafa and wget programs to be installed. chafa allows the image to be displayed in the terminal. On Debian-like systems:
sudo [ aptitude | apt ] install chafa wget
weather-moon.pl generates this result:

The image resolution depends on the capabilities of the terminal. Kitty, for example, displays the image perfectly, without any tearing or artifacts. The image above was generated by running the script from Emacs‘ EAF-terminal.
The NASA repository contains frames (hourly images) of the lunar phase throughout the year, but the URL where the images reside may change each year, which may require updating the weather-moon.pl script. To find the correct path, you can refer to the internal link for the lunar phase image for the current day on the NASA website: https://svs.gsfc.nasa.gov/gallery/moonphase/. The base URL specified in weather-moon.pl (https://svs.gsfc.nasa.gov/vis/a000000/a005400/a005415/frames/3840x2160_16x9_30p/plain/) is valid for the year 2025.