Get Weather Forecast in Terminal with Wego
Wego is a command-line tool that can be used to get weather information on your location or any area in the world. In this tutorial, we’ll look at how to install and use Wego on Ubuntu 16.04 LTS.
Install Wego on Ubuntu 16.04
Wego is written in Go language and hosted on Github so we first need to install Go language and then download Wego from Github.
Install go language
sudo apt install golang-go
Then set the $GOPATH environment variable. The following command sets
$HOME/go as the GOPATH. The Wego binary will be installed in
Next, add $GOPATH/bin to the user’s path.
We can also put the above two command at the end of
.bashrc file so they will be automatically executed every time we open up a terminal.
Now let’s download Wego from Github.
sudo apt install git go get -u github.com/schachmat/wego
After that, you need to set up your location. Wego supports two weather services: forecast.io and WorldWeatherOnline.com. As the latter no longer gives out free API, so this tutorial will demonstrate how to set up Wego with forecast.io.
Set up forecast.io Account
Create your account at https://developer.forecast.io/register. You will get an API key after registration.
Then create a .wegorc configuration file under your home directory.
Paste the following lines in the file.
backend=forecast.io location=40.748,-73.985 forecast-api-key=your-forecast.io-api-key
The location is identified by latitude and longitude. You can easily get your coordinates from Google Maps. Simply click your area and your latitude and longitude is shown in the address bar.
Save and close the file. Now you can type
wego command in the terminal to get weather forecast. It can show temperature, wind speed and direction, viewing distance, precipitation and probability.
By default, it shows forecast for the following 3 days. If you open up the .wegorc config file again, you will see wego has added other options.
You can change the value of days to 1~7. Other options can be changed as well.
- Wego v2.0 depends on ingo and therefore a go 1.5+ environment.
- A free forecast.io account can call the API 1000 times per day.
- forecast.io only supports latitude and longitude now. You can’t use city name to specify location.
There’s a similar tool named wttr.in which is very easy to use. All you have to do is to install
curl on your system.
sudo apt install curl
Then get weather information for your location, for example, New York.
curl wttr.in/"New York"
Even the weather of a domain name and IP address.
curl [email protected] curl [email protected]
Check help information.
wttr.in is in fact a front end of Wego.