2

Anyone knows a way to get a one line weather output in the terminal window with specified location?

So far I'm using curl wttr.in/city but I would like a one output like City, Sunny 0'.

I've found something like this (first answer): https://askubuntu.com/questions/390329/weather-from-terminal

Unfortunately it does not work. I've installed wget command with brew and tried running those three lines from .sh file.

2
  • Are you struggling to pick out the results from a correct download or are you needing help identifying a source to download? Why not edit this to show the exact site you've chosen to run from curl or wget if you just need help with awk or cut to strip out the parts you don't want to see.
    – bmike
    Commented Apr 24, 2016 at 15:18
  • This question doesn't seem related to OS X or Apple products in general.
    – ecnepsnai
    Commented Apr 25, 2016 at 19:17

1 Answer 1

1

Simplest solution is ansiweather which you can install with brew. The result looks like ansiweather result.

If you want to write you own command/function it's not that difficult. If the output from the online location is in json, or something similar. You can use jq to parse json, and only print what you need.

curl -s http://ip-api.com/json | jq -Cr .

Read the manual page of jq to learn how to use it.

I tried the API you're using above, that's not gonna help your case. Find some other one that replies in JSON. For example:

curl -s 'api.openweathermap.org/data/2.5/weather?q={CITY,COUNTRY_CODE}&APPID={GET_YOUR_API_KEY}' | jq -C '.name? .weather?.main?'

I haven't tested it personally, because you have to make an account to make a call, but you get the idea.

Comment if you get lost.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .