Get Weather from Command Line

By  on  

There's an awesome script making the rounds on Twitter and I've been as excited as everyone else so I thought I'd show it.  Many of us live eight hours a day within the command line (although I'm not a vim hippie like some of you) so I try to find new ways to accomplish tasks from within iTerm (like getting bitcoin value or stock quotes).  Many of these solutions include using cURL and this awesomeness is no exception!

curl weather

You can get weather information from command line using cURL and wttr.in:

# Allow geolocation
curl -4 wttr.in

# Request a city
curl -4 wttr.in/Madison

wttr.in does well to guess location if one isn't provided so in most cases you wont need to provide your city.

There you go, another awesome way to get the information you need from command line!

Recent Features

  • By
    Create a CSS Cube

    CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a language capable of creating deep, creative visuals.  Add animation and you've got something really neat.  Unfortunately each CSS cube tutorial I've read is a bit...

  • By
    Write Better JavaScript with Promises

    You've probably heard the talk around the water cooler about how promises are the future. All of the cool kids are using them, but you don't see what makes them so special. Can't you just use a callback? What's the big deal? In this article, we'll...

Incredible Demos

  • By
    Duplicate the jQuery Homepage Tooltips Using Dojo

    The jQuery homepage has a pretty suave tooltip-like effect as seen below: Here's how to accomplish this same effect using Dojo. The XHTML The above HTML was taken directly from the jQuery homepage -- no changes. The CSS The above CSS has been slightly modified to match the CSS rules already...

  • By
    Vertically Centering with Flexbox

    Vertically centering sibling child contents is a task we've long needed on the web but has always seemed way more difficult than it should be.  We initially used tables to accomplish the task, then moved on to CSS and JavaScript tricks because table layout was horribly...

Discussion

  1. Jeremy

    Frickin’ genius!

  2. Lis

    This is excellent! As a relative rube when it comes to the command line though, can someone kindly explain the purpose of -4 in the command? I seem to get the same results whether I include it or leave it out.

  3. David

    It looks like iTerm here translates/renders the curl response HTML output? Or curl implicitly does that (if so what version of curl are you using)? Because the raw HTML (unprocessed) does not look as nicely displayed as the screenshot. Only if you render the HTML will it look like that.

  4. Chris

    I created an (OS X only) to automatically show your local weather:

    https://gist.github.com/6343547a0169e9b6167d

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!