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

Álvaro Ramírez

08 April 2023 shell-maker, a maker of Emacs shells

A few weeks ago, I wrote about an experiment to bring ChatGPT to Emacs as a shell. I was fairly new to both ChatGPT and building anything on top of comint. It was a fun exercise, which also generated some interest.

As mentioned in the previous post, I took inspiration in other Emacs packages (primarily ielm) to figure out what I needed from comint. Soon, I got ChatGPT working.


As I was looking at OpenAI API docs, I learned about DALL-E: "an AI system that can create realistic images and art from a description in natural language."

Like ChatGPT, they also offered an API to DALL-E, so I figured I may as well try to write a shell for that too… and I did.


There was quite a bit of code duplication between the two Emacs shells I had just written. At the same time, I started hearing from folks about integrating other tools, some cloud-based, some local, proprietary, open source.. There's Cody, invoke-ai, llama.cpp, alpaca.cpp, and the list continues to grow.

With that in mind, I set out to reduce the code duplication and consolidate into a reusable package. And so shell-maker was born, a maker of Emacs shells.

shell-maker's internals aren't too different from the code I had before. It's still powered by comint, but instead offers a reusable convenience wrapper.

It takes little code to implement a shell, like the sophisticated new greeter-shell ;)


(require 'shell-maker)

(defvar greeter-shell--config
   :name "Greeter"
   (lambda (command _history callback error-callback)
     (funcall callback
              (format "Hello \"%s\"" command)

(defun greeter-shell ()
  "Start a Greeter shell."
  (shell-maker-start greeter-shell--config))

shell-maker is available on GitHub and currently bundled with chatgpt-shell. If there's enough interest and usage, I may just break it out into its own package. For now, it's convenient to keep with chatgpt-shell and dall-e-shell.

If you plug shell-maker into other tools, I'd love to hear about it.

Happy shell making!