Skip to main content

Get your daily dose of xkcd directly from the terminal! 🤩

Project description

xkcd cli tool

Lint and static code analysis on develop branch License: MIT Code style: black

Get your daily dose of xkcd directly from the terminal! 🤩

https://user-images.githubusercontent.com/3976183/163873282-f586f312-2643-4b77-af79-89e344091b2f.mp4

xkcd is a webcomic created by Randall Munroe. It is a comic of Language, Math, Romance and Sarcasm and a couple of other categories.

If kitty, iterm or any terminal that has support for the sixel file format is used as the terminal, the xkcd comic will be rendered directly in the terminal, otherwise the default viewer for PNG images is used. This tool requires fzf to be installed on the machine to filter available comics by their title.

Installation

With pip

Install this package directly from the Python Package Index (PyPI). The CLI tool requires Python >= 3.8 to be installed.

$ pip install dcs-xkcd-cli

This will install a CLI tool named xkcd which can be used as described below.

With pipx

Installation with pipx is similar to the pip variant above, but uses pipx instead of pip.

$ pipx install dcs-xkcd-cli

Note that with pipx, this package can be tried out without the need to install it permanently.

$ pipx run dcs-xkcd-cli <args>

Usage

Search by title

$ xkcd show

This functionality requires fzf to be installed.

Show latest xkcd comic

$ xkcd show --latest

Show random xkcd comic

$ xkcd show --random

Show xkcd comic by its ID

$ xkcd show --comic-id 207

Upscaling / width of comics

By default images are upscaled to match the terminal dimensions. This behavior can be controlled with the --terminal-scale-up / --no-terminal-scale-up options. Images can be also rendered with an explicit width by using the --width CLI option.

$ xkcd show --comic-id 207 --no-terminal-scale-up    # disable scaling
$ xkcd show --comic-id 207 --width 1200              # set explicit width

Disable rendering in terminals

$ xkcd show --no-terminal-graphics

This command will disable the automatic image protocol detection and directly open the image with the help of xdg-open in the default image viewer.

Disable or update cache

Under the hood this tool uses a cache which is updated once per day transparently. The cache is used to remember the list of xkcd comics from the archive.

To disable the cache, use the following command

$ xkcd show --no-cache

To update the cache manually, use the following command

$ xkcd update-cache

Development

This repository manages Python dependencies with poetry. To install the package and its dependencies run:

$ poetry install

The code is formatted with black and type checked with pyright.

Then run the the following commands to lint and test the code:

$ poetry run python -m black --check --diff .   # tests for any lint issues
$ poetry run python -m black .                  # auto-formats the code

$ poetry run python -m pyright                  # runs static code analysis

$ poetry run python -m pytest --cov="xkcd_cli/" --cov-report term --cov-report html   # run tests with code coverage report

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dcs-xkcd-cli-2.0.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

dcs_xkcd_cli-2.0.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file dcs-xkcd-cli-2.0.0.tar.gz.

File metadata

  • Download URL: dcs-xkcd-cli-2.0.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1029-azure

File hashes

Hashes for dcs-xkcd-cli-2.0.0.tar.gz
Algorithm Hash digest
SHA256 c6d83f948c2a5b64b4aeaa217b3d67f0b81483434da4d911c2a6b64f8993b2cc
MD5 21babf008f7082faf5189d8e4c708500
BLAKE2b-256 0e3546c3c98d618a7640ff275ac63bd07c022f114488bfd21c84450f321839ca

See more details on using hashes here.

File details

Details for the file dcs_xkcd_cli-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: dcs_xkcd_cli-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1029-azure

File hashes

Hashes for dcs_xkcd_cli-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76f32529f2b390a8cd82c51c1ef8cfa4b21f7aad2236ecb8cab16513dbcac6dd
MD5 7c52749f4751eae11c01e99690d3b989
BLAKE2b-256 3578ab40ebc2d8d0c6fee25ce57ff0ca351732480b13d4b8b981ba92f98a781b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page