I’ve been using Emacs in a terminal for some time now (an experience worth a blog post another day). One thing that bothered me a little was that the “splash screen” (what Emacs displays at the start) does not show the familiar Emacs logo. I decided to fix this.
The simplest approach I could think of was to generate the logo in ASCII art form and turn some knob to display it in a terminal. It turns out there is no such knob built in – but this is Emacs, so everything can be changed even if the Emacs devs didn’t think of it.
The splash screen is defined in startup.el. A quick scan revealed that on a graphic display, the function fancy-splash-screen is called (which displays the logo), and in a terminal it’s normal-splash-screen (which does not). There aren’t any variables I could find to customize it, but we have advice!
(defun insert-ascii-art-logo-on-splash-screen (&optional startup concise)
"Insert an ASCII-art Emacs logo on the normal splash screen."
(unless concise
(with-current-buffer "*GNU Emacs*"
(let ((inhibit-read-only t))
(goto-char (point-min))
(call-process "jp2a" nil t nil
"--invert"
(format "--width=%s" (/ (window-width) 2))
(expand-file-name "images/splash.png"
data-directory))
(insert "\n\n")))))
(advice-add 'normal-splash-screen
:after
#'insert-ascii-art-logo-on-splash-screen)
As you can see, the code is pretty simple – and the result is actually pretty cool! One thing I’ve learned while writing it was the existence of the jp2a utility; another was the data-directory variable. (If you are bored some day, say M-: (dired data-directory) RET and see what’s there!)
Of course, I could probably make the logo-in-the-terminal look much better with kitty-graphics.el – but where’s the fun in that?
Until next time!