Read xkcd from the comfort of your terminal
xkcd is probably the most popular webcomic with devs. It only seems right that you can read it from the comfort of your terminal via a xkcd
command.
Here is a summary of the dependencies:
- Kitty terminal. Kitty shows images via the
icat
kitten which is included in the default installation. - ImageMagick is used by Kitty under hood as far as I know.
- The utilties you find in most unix-like systems:
curl
,grep
,cut
, andperl
.
If you do not want to use Kitty, I believe iTerm2 has similar functionality with its imgcat
script. It is a minor change to adapt the script to use that instead.
It is a shell script. You can run it as ./xkcd
when the file is in the current working directory.
It is preferable to move it to an executable location and be able to run it using xkcd
anywhere e.g. move the xkcd file to /usr/local/bin on linux.
Usage: xkcd [-l|--latest] [-r|--random] [-h|--help]
-h, --help Print the help page.
-l, --latest Show the latest comic.
-r, --random Show a random comic.
For example, to show a random comic, run the command xkcd --random
.
I wrote 2 versions of this with the same interface:
- This is the version that scrapes the webpages (main branch).
- The alternative version uses the web api, go to the json branch to check that out.
I discuss the code in this article -- Read XKCD in the terminal with some bash magic.
You can show your appreciation by:
- Buying me a coffee or sponsoring me. This will offer me encouragement to continue, and can provide a path to dedicating more time to open-source in the future.
- Starring the repo 🌟. This will help other people find this.
Thank you! 🙏
XKCD is licensed under a Creative Commons Attribution-NonCommercial 2.5 License.