58 ms·
`curl wttr.in`: Weather in your terminal
- trinovantes 4y agoIf only there's a $PS1 version
- queuebert 4y agoThat would be cool, but how would you condense the information enough that it's both useful and doesn't take up 2/3 of a line?
- CrispinS 4y agoEmojis? For the current weather, a single emoji could convey quite a lot; e.g. a snowflake for sub-60 weather (I have a low tolerance for cold), a sun for 60-80, fire emoji for 80+... Now, I don't know if anyone truly needs the weather in their terminal prompt, but it is doable.
- behnamoh 4y agoperhaps the RPROMPT would be better. i usually use it to show time %T.
- Kim_Bruning 4y agocurl 'wttr.in/?format=%c' see the readme here for all options: https://github.com/chubin/wttr.in https://github.com/chubin/wttr.in
- dredmorbius 4y agoMicrocharts or sparklines are another option. I've seen a few implementations along these lines for shell prompts / shell use. This might be useful for temperature, humidity, wind, preciptitation, and similar measures, either as quantities or timelines. https://en.wikipedia.org/wiki/Sparkline https://en.wikipedia.org/wiki/Sparkline https://github.com/deeplook/sparklines https://github.com/deeplook/sparklines Similar: https://www.linux-magazine.com/Issues/2016/183/Calc-Conditional-Formatting https://www.linux-magazine.com/Issues/2016/183/Calc-Conditio...
- LeonB 4y agoIt’s provides different formats, I was using this one in the past from Powershell invoke-restmethod wttr.in/?format=4 …and I think it was quite compact
- derwiki 4y agoI might be a heathen, but my PS1 is as long as it wants to be, and ends with \n$
- Shared404 4y agoI feel like I should hate this... But I don't. I may steal this idea later, than there would be a whole 2 of us!
- queuebert 4y agoThat's a great old-school idea. I used to run it that way but forgot. I have also started adding a time stamp to the second, so that when I run long commands and come back later in a tmux session I can see when it finished.
- enriquto 4y ago> how would you condense the information enough that it's both useful and doesn't take up 2/3 of a line? There's a method that takes 0 space: just change the color of the prompt symbol depending on the weather status (sunny, cloudy, raining, snowing).
- behnamoh 4y agoi know you’re referring to the shell prompt, but it reminded me that PowerShell file extension is also *.ps1 (which I find strange as I’m not used to seeing numbers in file extensions). didn’t this really come up when MS was designing PowerShell?
- smegsicle 4y agoi think they count the namespace pollution as free advertising
- mrweasel 4y agoIt might just be me, but I never saw the usefulness in widgets that shows the current weather, at your current location. I mean can’t you just look out the window? Stuffing a three days weather report into $PS1 might be to much information for a prompt.
- teddyh 4y agoI’m reminded of the old discussion of which clock program for X11 consumed the least resources and screen size. It concluded with something like: “Of course, the clock which consumes no resources, and does not take any screen space, is the clock which hangs on your wall.”.
- jona-f 4y agoI have to get up and walk to the window, so looking it up in the terminal is much faster. But I agree that it feels somewhat detached from nature. Also the thermometer at the window varies a lot with direct sunlight or wind, so i find these weather services give a better estimate to what i should be wearing when i go outside.
- prezjordan 4y agoCute idea!
- innocenat 4y agoI have to scroll all they way down to the buttom to find the information source -- WorldWeatherOnline. Does people not care about where their whether data is sourced from? Living in Japan, I have always been wary of these type of service, since I find a lot of them really inaccurate. And I just checked, Tokyo show 15C on that website, while high resolution current weather information from Japan Metrological Agency show 18C.
- LeoPanthera 4y agoThis is why I like Windy.com. They give you the output directly from the various weather models and you can actually see them all in parallel or just pick whichever one works best for your location.
- brewdad 4y agoLiving in the PNW where predicting snowfall can be problematic to say the least, I love looking at the various windy.com models. One particular storm, that lead to about an inch of sticking snow this past winter had ranges from 2-20 inches predicted by the various models. The worst part is the 2 inch prediction came from the model that is generally considered the least reliable for our area.
- is_true 4y agoI think you are comparing a weather model with the current reading from a weather station.
- cmeacham98 4y agoThere's also `curl v2.wttr.in`, but imho I like the original better.
- cercatrova 4y agoI like this command, as an alias, it combines all wttr.in's versions (v3 doesn't quite seem to work yet): alias weather="curl wttr.in && curl v2.wttr.in && curl v3.wttr.in"
- mcint 4y agov3 does work, but you need to guess the appropriate region. The Bayern.sxl example works, and is a good way to prove to yourself that your terminal is compatible, instead of your hoped-for region not being indexed. curl v3.wttr.in/Bayern.sxl curl v3.wttr.in/California.sxl
- cercatrova 4y agoYeah is there a list of the sxl regions? I tried a few, like Paris, and they didn't work so I gave up.
- taf2 4y agoThis is really neat... vim ~/.bashrc ``` alias weather='/usr/bin/curl wttr.in' ``` :wq and now: weather
- cercatrova 4y agoHeh, I did the exact same thing. I actually did alias weather="curl wttr.in && curl v2.wttr.in && curl v3.wttr.in" so that it shows me the temperature chart and map as well. Well, v3's map isn't working so I commented that out for now but they say it should work in the future.
- behnamoh 4y agobut this curls the app each time you invoke it!
- cercatrova 4y agoYes? That's how it works, not sure what you mean.
- behnamoh 4y agoyou’re right. for a moment I thought the app is _installed_ using curl.
- Kim_Bruning 4y agoif you do curl wttr.in/:help Tou get a help document, which also shows you a way to get a suggested bash function; to wit: curl wttr.in/:bash.function
- dgl 4y agoRemember with this kind of thing you're trusting the remote site with access to your terminal emulator. There have been various security problems with some more advanced terminals and escape sequences in the past[1][2]. Personally I think it's a cute thing and have implemented some similar little easter eggs to this via: curl ip.wtf/moo [1]: https://blog.mozilla.org/security/2019/10/09/iterm2-critical-issue-moss-audit/ https://blog.mozilla.org/security/2019/10/09/iterm2-critical... [2]: https://packetstormsecurity.com/files/162621/rxvt-2.7.0-rxvt-unicode-9.22-Code-Execution.html https://packetstormsecurity.com/files/162621/rxvt-2.7.0-rxvt...
- mateo1 4y agoI'm speechless. I never expected running curl could lead to such a security disaster.
- daptaq 4y agoThe terminal (or rather terminal emulation) is a mistake, people should stop glorifying it. It has no inherent value, beyond being able to run historical software that was bound to a terminal. Most of all one should stop confusing the terminal and the shell, which remains an interesting concept.
- dredmorbius 4y agoThen where should the shell be run?
- hprotagonist 4y agoon the DOM, of course /s
- daptaq 4y agoAcme and Emacs give good examples of how a non-terminal shell session can look like. They also make clear how a good CLI application should behave like.
- 4y ago
- buzzdenver 4y agoI get "Weather report: not found" on the first line and then a 3 day forecast for idk what location.
- igor_chubin 4y agotry `curl wttr.in/Munich` (with your location specified instead of Munich)
- buzzdenver 4y agoThanks. The odd thing is that the weather report looks somewhat accurate. I'm not behind any proxy. Let me know if I can help debug.
- igor_chubin 4y agoplease send me your IP or at least its 3 first octets to igor AT chub.in
- cercatrova 4y agoMore cool console services like this one: https://github.com/chubin/awesome-console-services https://github.com/chubin/awesome-console-services curl wttr.in/Moon Shows moon phases curl rate.sx Shows cryptocurrency exchange rates, from the same author as wttr.in I sourced the above commands from a previous HN post: https://news.ycombinator.com/item?id=23646953 https://news.ycombinator.com/item?id=23646953
- nickstinemates 4y agorate.sx is very good. much better than all of the desktop client trackers out there and the web ones with too much granularity. sometimes i don't want to see the candles i just want to see the price of a particular coin
- tonto 4y agoA very fun way to have this, tmux status bar weather! `set -g status-left '#(curl "wttr.in/YourTown?u&format=3")'`. This way you can always see the latest :)
- every 4y agoI simply use the ansiweather app [0] through an alias in the terminal... [0]: https://github.com/fcambus/ansiweather https://github.com/fcambus/ansiweather
- deleted 4y ago[deleted]
- nooyurrsdey 4y agoOnly HN can be so critical of what is a really cool project. Honestly this is a great _simple_ way to access weather without leaving my terminal. Love the basic ASCII graphics. I noticed it's a LOT faster when I provide the city, probably because it doesn't have to look it up from IP: ``` curl wttr.in/atlanta ``` Nice work.
- NmAmDa 4y agoPeople on HN should he normally worried about running 'curl' from any untrustworthy sources because that is a security issue. An example -https://www.onsecurity.io/blog/careless-with-curl-dont-be/ https://www.onsecurity.io/blog/careless-with-curl-dont-be/ -
- galenguyer 4y agoThis talks about concerns with piping curl into bash. It doesn't address any issues with just curling arbitrary data
- mekster 4y agoIt's just cool but practically I never check weather until I'm about to leave home and then I'll just check a local weather app on my phone which should give more accurate and detailed info than a service that covers the entire world with presumably varying degree of accuracy.
- nickstinemates 4y agobut imagine if you're in a bunker hacking on your fav project, no artificial light and you wonder.. shall i go to the surface? you curl this website and, if tolerable weather conditions, you plan your ascent.
- hulitu 4y agoThere isno weather app which gives you the status of nuclear downfall.
- aftbit 4y agoIn the USA, I like the National Weather Service direct APIs. I wish I could get more granular forecast data, both in time and space, but they forecast dewpoint/humidity, which is really nice.
- dredmorbius 4y agoAny links on that? I wrote a set of scripts --- it takes thee, a bash function, sed, and awk --- to parse the dumped formatted HTML to a more usable form on a terminal. Raw APIs might be more convenient / less complicated.
- hoppyhoppy2 4y agohttps://www.weather.gov/documentation/services-web-api https://www.weather.gov/documentation/services-web-api
- dredmorbius 4y agoThanks!
- aftbit 4y agoYes, I am using a handful of different APIs. My full terminal weather setup deserves its own blog post... but until then, here are some zsh snippets, scripts, and curls to get you started. Rough weather information for next days and hours: # Find zone with curl https://api.weather.gov/points/40.5878,-103.0694 ZONE=${ZONE:-CAZ508} echo "Forecast for zone $ZONE" curl -s -A MyWeather/1.0 https://api.weather.gov/zones/forecast/$ZONE/forecast \ | jq -r '.properties.periods[] | [.name, .detailedForecast] | join("\t")' \ | column -t -s $'\t' # Find grid with same curl GRID=${GRID:-MTR/93,131} echo "" echo "Next 24 hours for grid $GRID" curl -s -A MyWeather/1.0 https://api.weather.gov/gridpoints/$GRID/forecast/hourly \ | jq --arg date $(date -Is) -r '.properties.periods[] | select(.startTime >= $date) | [(.startTime), ((.temperature|tostring) + " " + .temperatureUnit), (.windSpeed + " @ " + .windDirection), .shortForecast] | join("\t")' \ | column -t -s $'\t' \ | head -n 24 Weather discussion script (also using regexps to parse HTML): https://gist.github.com/lachesis/6c7e5020b112fe8d7bcc83d99dae1f5f https://gist.github.com/lachesis/6c7e5020b112fe8d7bcc83d99da... Some docs on the "DWML rest API" that provides the dewpoint/humidity forecasts that I mentioned earlier: https://graphical.weather.gov/xml/rest.php https://graphical.weather.gov/xml/rest.php https://graphical.weather.gov/xml/DWMLgen/schema/latest_DWML.txt https://graphical.weather.gov/xml/DWMLgen/schema/latest_DWML... https://graphical.weather.gov/xml/docs/elementInputNames.php https://graphical.weather.gov/xml/docs/elementInputNames.php Here's the script I use to access that API but it is still under active development and is pretty tailored for my situation. Please forgive jankiness. Give it LAT / LNG environment variables. https://gist.github.com/lachesis/480a1811c75999205cb17a119b49ef94 https://gist.github.com/lachesis/480a1811c75999205cb17a119b4... Bonus points, for CA fire season, here's a script that shows PM2.5 for AirNow stations near a certain LAT/LNG: https://gist.github.com/lachesis/a47212c848430e16e7d1ec6d85515fc3 https://gist.github.com/lachesis/a47212c848430e16e7d1ec6d855...
- simlan 4y agoLove it. Was expecting maybe one limited end-point and was scrolling 5mins through all the features. Very cool
- granddave 4y agoThis is a really nice service and I have used it for quite some time. Just a small reminder; to relieve the wttr servers, please cache the results on disk if you for example want to have a higher refresh rate on your tmux status bar. See my dotfiles repo [1] if you're interested in such implementation [1] https://github.com/Granddave/dotfiles/tree/master/tmux https://github.com/Granddave/dotfiles/tree/master/tmux
- agumonkey 4y agoI wonder how far you could push the web into this mode. Everything in tiny ascii strips. Even shopping, or other needs. A challenge in cute minimalism (not crippled).
- Kim_Bruning 4y agoso the obvious (for me) thing to try was: watch -n 600 -c 'curl -s v2.wttr.in/' This ALMOST works, but somehow it messes up the formatting for me. For some reason watch doesn't pass through formatting cleanly or so?
- igor_chubin 4y agoThis is not a problem with wttr.in, this is a problem of `watch`. It is a known issue: it can't render ANSI output. You can try to run it with any command that has ANSI output, and you will see it. As a simple alternative, you write your own 'watch' like this: while true; do curl -s wttr.in; sleep 60; clear; done
- teddyh 4y agoWhen writing these things, I prefer using the “sleep” command as the while condition. This way, the loop is easier to break out of. I.e. when I press Ctrl-C, the sleep command returns a non-zero exit code, and the while loop terminates gracefully: while sleep 60; do clear; curl -s wttr.in; done Otherwise, I very often get a loop which stubbornly refuses to abort, and I have to hammer both Ctrl-C and Ctrl-\ to make it stop. The downside is, of course, that I have to wait 60 seconds (in this case) the first time. When this is a problem, I just unroll the loop slightly and add an extra invocation to the beginning: clear; curl -s wttr.in; while sleep 60; do clear; curl -s wttr.in; done This could be generalized into a terminal watch function: termwatch(){ delay="$1"; shift; clear; "$@"; while sleep "$delay"; do clear; "$@"; done; } termwatch 60 curl -s wttr.in
- Kim_Bruning 4y agoThanks for your help igor_chubin and teddyh! According to The Fine Manual: watch --color (-c for short) , should render color correctly, eg. watch --color ls --color but watch --color curl -s v2.wttr.in doesn't quite play ball. In the end I went with something like your solution. I didn't need to put the sleep 60 as the first operation though. #!/bin/bash while true; do clear curl -s v2.wttr.in sleep 100 done ^C breaks out of this loop just fine on my system.
- sigg3 4y agoI'm going to add that if you live in Norway, YR has nice weather data available for free (required by law). Shameless plug for my little CLI tool when I was beginning to learn go: https://github.com/sigg3/weather_query/ https://github.com/sigg3/weather_query/
- nickstinemates 4y agothis is really nice, i like the rendering and simplicity. it's aesthetically pleasing. overall 10/10 experience.
- nickjj 4y agoI've had this shell function / alias set up for years: weather () { curl "https://wttr.in/${1}" } This lets you run: weather nyc, a zip code and everything else wttr.in supports.
- deleted 4y ago[deleted]
- secondcoming 4y agoThat is very lovely. Well done!
- shdon 4y agoI'm a little amused by its weather report classifying the night as "Sunny", when it probably just means the sky will be clear.
- netsharc 4y agoSeems like it breaks when it can't find the geo-location, it says "Weather report: not found" but still shows the weather forecast from... somewhere?
- anovikov 4y agocool widget but sucks on a mac where default background is white. yellow stuff is almost invisible.
- queuebert 4y agoYou can change the Terminal background on a Mac.
- nixpulvis 4y agoSo I do a basic `curl wttr.in` and I get back a line "Weather report: not found" followed however, by what appears to be a full weather report. Two things: 1. Either give me an error and exit, or warn me about something meaningful 2. Show me the location of the weather report, as it stands I'm left guessing Otherwise, it's nice to see people making simple text interfaces for important data like this.
- yasenn 4y agoIgor created several great cli projects like cheat.sh[1], late.nz[2], QRenco.de[3],rate.sx[4] Also, he maintains the awesome-console-services[5] list [1] https://github.com/chubin/cheat.sh https://github.com/chubin/cheat.sh [2] https://github.com/chubin/late.nz https://github.com/chubin/late.nz [3] https://github.com/chubin/qrenco.de https://github.com/chubin/qrenco.de [4] https://github.com/chubin/rate.sx https://github.com/chubin/rate.sx [5] https://github.com/chubin/awesome-console-services https://github.com/chubin/awesome-console-services
- pschastain 4y agoA nice idea but it gives the wrong info for Spokane, WA, USA
- nazka 4y agoMy little custom command (HN formatting break it all so need to be nicely formatted again). alias weather=weather function weather() { if [ $# -le 2 ]; then Command="wttr.in/$1" if [ $# -eq 2 ]; then Command="$Command,$2" fi fi Command="curl ${Command// /%20}" eval $Command }
- sylware 4y agointerop done the right way: this guy is going to be in trouble with the web javascript kiddies. Yes, if this guy is a state-sponsored computer security hacker, he could pown the 3, maybe 4, ppl (and I am one of them) using its http services via curl and our terminals or image format parsers or etc. Is this worth for that many ppl? Anyways, that's too sexy, I am willing to take the bait. That said, I could use an official/trusted online source for the weather information and format it myself (I guess I would get a CSV or json or xml file).
- pesnk 4y agoin ~ 2016 I built a plugin for on-my-fish to simplify the process of curling wttr.in https://github.com/oh-my-fish/plugin-wttr https://github.com/oh-my-fish/plugin-wttr. From today I'm still using this plugin a lot. Checking out the weather on your terminal turns out to be faster than open a weather website or unlock my phone and check in out a weather app.