LinuxCommandLibrary

ansiweather

Display weather information in the terminal

TLDR

Display a [f]orecast using metric [u]nits for the next seven days for a specific [l]ocation

$ ansiweather -u metric -f 7 -l [Rzeszow,PL]
copy

Display a [F]orecast for the next five days showing [s]ymbols and [d]aylight data for your current location
$ ansiweather -F -s true -d true
copy

Display today's [w]ind and [h]umidity data for your current location
$ ansiweather -w true -h true
copy

SYNOPSIS

ansiweather [OPTIONS]

PARAMETERS

--location LOCATION
    Specifies the geographical location for weather data (e.g., London,GB, 90210,US, 34.05,-118.25).

--units UNITS
    Sets the unit system for temperature and wind: metric, imperial, or kelvin.

--language LANG_CODE
    Sets the display language (e.g., en for English, fr for French).

--display MODE
    Controls which weather elements are displayed. MODE can be basic, forecast, full, alert, or a comma-separated list of elements (e.g., temp,humidity).

--apikey API_KEY
    Provides the OpenWeatherMap API key directly as a command-line argument.

--config FILE_PATH
    Specifies an alternative configuration file path instead of the default.

--forecast-days DAYS
    Sets the number of days for the weather forecast (typically 1-5 days).

--symbols true|false
    Enables or disables the use of Unicode symbols in the output.

--colors true|false
    Enables or disables ANSI colors in the output.

--output FORMAT
    Specifies the output format (e.g., plain for no ANSI codes, ansi for default).

--verbose
    Displays additional debug information, useful for troubleshooting.

--version
    Shows the ansiweather version information and exits.

--help
    Displays the command's help message and exits.

DESCRIPTION

ansiweather is a lightweight command-line tool that fetches and displays current weather conditions and forecasts directly in your terminal. Written as a shell script, it utilizes the OpenWeatherMap API to retrieve data, presenting it with colorful ANSI escape codes and Unicode symbols for an aesthetically pleasing and easily readable output. Users can customize the location, units (metric or imperial), language, and specific information displayed (e.g., temperature, humidity, wind). It's popular for quick weather checks, often integrated into shell prompts or status bars. An OpenWeatherMap API key is required and can be configured via a file or command-line argument.

CAVEATS

API Key Requirement: ansiweather requires a free OpenWeatherMap API key, which must be obtained from their website and properly configured. Free tier keys have rate limits.
External Dependency: The command relies entirely on the OpenWeatherMap API; functionality ceases if the API is unreachable, down, or if the API key is invalid.
Terminal Support: Optimal display of ANSI colors and Unicode symbols depends on the capabilities of your terminal emulator and the fonts installed on your system.

CONFIGURATION FILE

ansiweather typically reads its default settings from a configuration file, commonly located at ~/.config/ansiweather/config or ~/.ansiweather.conf. This file allows users to set persistent options such as the API key, default location, and preferred units, reducing the need for repetitive command-line arguments during daily use.

API KEY SETUP

To enable ansiweather to fetch weather data, users must register at the OpenWeatherMap website to obtain a free API key. This key then needs to be placed into the ansiweather configuration file (e.g., by setting API_KEY="your_key_here") or provided directly with each invocation using the --apikey option. Without a valid and active API key, ansiweather cannot retrieve weather information.

HISTORY

ansiweather was developed by fcambus as an open-source shell script. Its creation aimed to offer a simple, visually appealing method for displaying weather in the terminal. Leveraging existing shell features and the OpenWeatherMap API, it quickly became popular among command-line users for its customizability and low resource usage, commonly integrated into shell startup files like .bashrc or .zshrc.

SEE ALSO

curl(1): Common tool for transferring data with URLs, often used internally by ansiweather to fetch API data., jq(1): A lightweight and flexible command-line JSON processor, frequently used for parsing API responses., wttr.in: A web service providing weather information directly in the terminal, accessible via curl.

Copied to clipboard