index rss mastodon twitter github linkedin email
Álvaro Ramírez
sponsor

Álvaro Ramírez

24 November 2019 Wizard zines comics in Emacs eshell

Over at wizardzines.com, Julia Evans authors wonderful zines on topics like git, networking, linux, command-line utilities, and others. Some zines are paid. Some are free. No affiliation here, just a fan.

A little while ago, Julia tweeted about a utility she's building to view her original comics on similar topics. I instantly thought it'd be a fun tool to implement for Emacs eshell.

Since then, I subscribed to wizardzines.com/saturday-comics and received a few comics (awk, tar, and bash tricks). I saved them locally (using topic name and dropping file extensions).

ls -1 ~/Downloads/wizardzines-comics/
awk
bash
tar

By no means battle-tested, but here's an elisp snippet defining the ecomic command. It displays inlined comics in the handy eshell.

(require 'eshell)
(require 'iimage)

(defvar wizardzines-comics-path "~/Downloads/wizardzines-comics")

(defun eshell/ecomic (&rest args)
  "Display command comic in ARGS.
Note: ensure comic images live in `wizardzines-comics-path', named with
command name and no extension."
  (eshell-eval-using-options
   "ecomic" args
   '((?h "help" nil nil "show this usage screen")
     :external "ecomic"
     :show-usage
     :usage "COMMAND

Show COMMAND comic from Julia Evans' https://wizardzines.com/saturday-comics")
   (let* ((command (nth 0 (eshell-stringify-list (eshell-flatten-list args))))
          (image-fpath (concat (file-name-as-directory
                                (expand-file-name wizardzines-comics-path))
                               command)))
     (unless (file-exists-p image-fpath)
       (error "comic: \"%s\" not found :-(" command))
     (eshell-buffered-print "\n")
     (add-text-properties 0 (length image-fpath)
                          `(display ,(create-image image-fpath)
                                    modification-hooks
                                    (iimage-modification-hook))
                          image-fpath)
     (eshell-buffered-print image-fpath)
     (eshell-flush))))

ecomic.gif

comments on twitter

Updates

  • Tweaked title.