npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

terminal-weather

v1.1.2

Published

A Location-based Terminal Weather utility using OpenWeatherMap's API

Downloads

6

Readme

terminal-weather

Terminal weather is a minimal, flexible command-line tool for displaying the current weather in your location, optimized for rapid re-rendering in your terminal prompt.

Requirements

Dependencies

Installation

  • Run npm install -g terminal-weather
  • Run terminal-weather configure to set it up. You will be prompted for your open weathermap.org API key as well the default temperature unit.

Which Services It Uses

Terminal-weather uses the following APIs:

Caching and Module loading

  • terminal-weather adheres to openweathermap.org's limit of 1 http call per ten-minute interval. The rest of the time it prints a cached value.
  • terminal-weather loads in a progressive way. Because the most frequent case is retrieving cached data, only the modules required for that are loaded. In case of a cache expiration, the additional modules required to retreive new weather data are loaded. The point is to maintain a seamless terminal experience when embedding terminal-weather in your prompt (see below).

Usage


    terminal-weather

    Usage: terminal-weather
       or: terminal-weather [options],                  ex: terminal-weather -p 
       or: terminal-weather configure,                  ex: terminal-weather configure
       or: terminal-weather show (display | config),    ex: terminal-weather show display
       or: terminal-weather uninstall,                  ex: terminal-weather uninstall 

    Options:
        -h, --help                                      print this usage page
        -n, --no-cache                                  invalidate cache before printing weather string  
        -p, --prompt                                    print weather string with no trailing new line. Useful for embedding in your terminal prompt.
        -d, --display=DISPLAY_MODE                      get or set display mode.
        -f, --format=FORMAT_STRING                      get or set the format string determining the weather string output.
        -u, --units=UNIT_TYPE                           get or set temp unit type.

Tips

If you update your display, units and/or format string, the update will not be visible until the cache expires. To make the effects immediately visible, pass the -n flag to explicitly invalidate the cache at the same time. E.g.:

terminal-weather -n --display=icon
terminal-weather -nd=icon 

Controlling the Output

To configure the order of terminal-weather's information, pass a string of characters from the list below to the format command.

T: Temperature

D: Display

The default format string is 'T D ', which renders something like '73° F clouds ', assuming that your display setting is text. The format string is space-sensitive, so you can control the spacing how you want.

Example: $ terminal-weather format 'D T '.

Note: the following weather information is forthcoming for the openweathermap.org api:

H: Humidity

P: Atmospheric Pressure

R: Range (hi/lo)

Configuration

  • Run terminal-weather configure and give terminal-weather the values it needs to store so it can continually query the api.
  • This configuration file is stored in the application's root directory (run terminal-weather show config to see the location of this file).

Getting terminal-weather into your terminal prompt

If you want to include terminal-weather in your bash prompt, there are a couple things you need to do:

  1. Make sure that /usr/local/bin is in your $PATH so that your shell can locate it. If after installing terminal weather, you can't run terminal-weather from your terminal, you may have not installed it globally (using the -g flag).

  2. Add the following lines to your ~/.bashrc file:

     # a function to insert the terminal-weather bash fn inside the PS1 variable
     set_bash_prompt() {
         PS1="$(terminal-weather -p)\u@[\h]$ $(history -n)"
     }
    
     # include above fn in prompt command variable so the prompt is reset each time it is rendered
     PROMPT_COMMAND="set_bash_prompt; $PROMPT_COMMAND"

Known Issues

Terminal weather's responsiveness seems to degrade if you source your ~/.bashrc multiple times from within a shell. Try running exec $SHELL -l.

Removing terminal-weather

  • First (definitely do this first!!!), remove terminal weather call from the bash prompt in your ~/.bashrc file
  • run terminal-weather uninstall. This is equivalent to running npm uninstall -g terminal-weather.