Checking weather: purpose of the command
There’s no shortage of methods to retrieve a weather report, the web is full of weather resources, everyones iPhone, Apple Watch, and smartphone has a weather app, Siri can tell you the weather, and you can even get the current weather in the menu bar of OS X or from Spotlight on the Mac too.
But for command line users, none of those options are particularly ideal, since it means leaving the command line and the task at hand.
Thanks to an interesting usage of the finger utility, you can quickly retrieve a weather report and weather forecast for virtually any city in the world, right from the command line.
With this trick you’ll see the temperature forecast (in celsius) for the day, wind direction and wind speed, precipitation and precipitation type (rain, showers, sleet, snow, etc), depth of precipitation, and more. This works with any command line that has the finger tool, whether you’re in Mac OS X, linux, BSD, Windows, it doesn’t matter, it will work the same.
To try this out yourself on the Mac, launch the OS X Terminal found in /Applications/Utilities/ and type the following command syntax:
finger (city name)@graph.no
For example, to get the weather forecast for Montreal Canada, you would use the following syntax at the command line:
This will return a full graph of weather and forecast in ASCII format, with extended details about the temperature and weather types.
The service is quite fast, here’s a real time look at weather retrieval in animated gif form:
One potential frustration for those in the USA is weather temperatures are reported in the globally acknowledged Celsius rather than the more physically precise Fahrenheit, and at the moment there is no way to change that, but that’s not much of a complaint and you can always get Siri to convert Celsius to Fahrenheit for you if need be.
You can also get a shorter forecast by prepending o: to the city name like so:
That will report a much shorter version of the forecast without having the ASCII temperature graph, looking like the following:
montreal at 22:00: -6 C, 5.3 mps wind from W.
The shorter version is shown at the bottom of the screenshot:
Again, adjust the city name to get a different city forecast.
This is a pretty handy tool for getting weather from the command line quickly, and the short version is great for scripting, the MOTD, or quick checks.
If you know of another method to retrieve forecasts, temperature, weather, and other meteorological data from the command line, share it with us in the comments.
Source: OS X Daily