I want to find the current weather of a particular city or my location from terminal. Is there any command-line weather app?
I want to find the current weather of a particular city or my location from terminal. Is there any command-line weather app?
Simply enter the following in a terminal:
And will get your location from
/etc/timezone
. Otherwisecurl wttr.in/your_location
. For example, for Tehran:Which gives you:
You can also compare two cities:
Source code of developer is available on Github.
Search for your city at http://www.accuweather.com and replace the URL in the following script with the URL for your city:
Sample output:
Here's a great semi-graphical command line utility written in Go:
https://github.com/schachmat/wego/
You'll need to install Go and setup some API stuff, but the instructions are there. Here's a sample pic:
I have got one more way .
Open your
.bashrc
file and then paste this code at the bottomThen save & close your
.bashrc
file.now type
bash
to update the file.then type
for example
ansiweather
AnsiWeather is a Shell script for displaying the current weather conditions in your terminal, with support for ANSI colors and Unicode symbols. Weather data comes from the OpenWeatherMap free weather API.
https://github.com/fcambus/ansiweather
First you need to install the weather-util package, to do that just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
You’ll need your local weather code.
After installation you can run
weather -i <code>
. The code you get from the link above. For a list of available options, you can runweather
Weather infoTry using
also a program that comes pre-installed with ubuntu called inxi will give you all types of stats on your computer and it does a weather output.
command: inxi --help
command: inxi -w
command: inxi -wxxx
I have got one more way .
Open your .bashrc file and then paste this code at the bottom
Save & close your
.bashrc
file and run the following command to update bash:then type
W
upper caseFor even shorter weather output openweathermap.org provides weather data in json format.
The filds from the JSON can then be obtained with a JSON parser like jq i.e..
I wrote a q&d weather-fetch script, wich gets the current temperature, icon and description of weather, then stores a unicode symbol corresponding to the icon and outputs it like
☂ 6°C
I regularly update via cronjob and then use the output in my tray status.
An API-key is needed for openweathermap - you may send 1000 requests free of charge per day.
The JSON contains further fields, i.e. forecast data, wind etc. – you can parse them, too, if you want. A description of the API can be found at https://openweathermap.org/current#one .
Unfortunatly some weather symbols are not represented in the Ubuntufont… feel free to adjust.
Here's my script. Change location if you don't life in Hamburg,DE and replace dummy value with your API-key. Depends on curl and jq.
EDIT 2022-07-09: Since tuxnet24.de does not provide weather anymore. I changed the provider to openweathermap. (this also involves json beeing parsed instead of xml in the former version) /EDIT