cashmere

cashmere

kitty-graphics.el v0.4.0: Sixel, Text Sizing, and agent-shell

After the v0.2.1 release, I went quiet for a while. Not because I lost interest, but because I was building the biggest update so far. v0.4.0 brings three major features: Sixel graphics support, the text sizing protocol for org headings, and agent-shell integration.

This post covers everything new in v0.4.0.

Sixel Support

The library no longer requires Kitty. I abstracted the graphics backend so it can speak both the Kitty image protocol and Sixel. Auto-detection happens via DA1 query. If your terminal supports Sixel, kitty-graphics will use it automatically. No configuration needed.

Tested and confirmed working in foot, xterm, Konsole, mlterm, and mintty.

img l One thing to keep in mind: the Kitty image protocol is still superior in terms of speed and image quality. Kitty gives you truecolor rendering and stateful image management. Sixel tops out at 256 colors and requires re-transmitting the image data on every redraw. If your terminal supports both, prefer Kitty.

The Sixel backend reuses the same overlay system, cache, and refresh cycle as the Kitty backend. All existing features (org inline images, LaTeX previews, doc-view, image-mode, dirvish) work with both protocols.

Text Sizing Protocol (OSC 66)

This one is new territory. We can now render org headings at scaled sizes. * Heading renders at 2x, ** Sub at 1.5x, *** Deep at 1.2x. It looks like proper typographic hierarchy, right inside terminal Emacs.

img

The implementation uses OSC 66 escape sequences to tell the terminal to render text at a different scale. Overlays are placed on top of heading lines and emit the scaled text. Folding and unfolding headings works correctly. Scrolling works correctly. The refresh cycle tracks overlay positions and cleans up stale renders.

A preview mode temporarily disables packages that conflict with the overlays (org-modern, org-appear, olivetti, etc.) for clean rendering. You can toggle images while text sizing is active, though not both at the same time yet.

Take this feature with a grain of salt. OSC 66 is very new and there are not many implementations out there. Right now it requires Kitty >= 0.40.0, which is the only terminal that implements OSC 66 with scale support.

I will keep improving this. I think it is genuinely great eye candy, and something I had never seen before in a terminal. Someone mentioned it under one of my Reddit threads and I had no idea it existed. If you feel mentioned, thanks.

agent-shell Support

Thanks to Lenbok, kitty-graphics now works inside agent-shell sessions. Images display correctly in agent-shell buffers. This came in as PR #3.

Bug Fixes and Polish

What Comes Next

tmux support

tmux already supports Sixel, so the Sixel backend will work there out of the box. There is also an in-progress branch adding Kitty image protocol support to tmux. If you already use Kitty directly, I would stick with it. The Kitty protocol gives you stateful image management, truecolor rendering, and a smoother experience overall.

Package renaming?

I am thinking about renaming the project to something like terminal-gfx. We now cover more than one protocol and are starting to stabilize the text protocol as well. This is my first project with people actually using it, so if you have suggestions or feedback, I would love to hear it.

If I do rename it, I will make sure your existing configuration does not break. Shoutouts to neovim and its stable ecosystem hust hust.

Installation

Drop kitty-graphics.el into your load path and enable the mode:

(require 'kitty-graphics)
(kitty-graphics-mode 1)

Or with use-package and straight.el:

(use-package kitty-graphics
  :straight (:host github :repo "cashmeredev/kitty-graphics.el")
  :if (not (display-graphic-p))
  :config
  (kitty-graphics-mode 1))

Note that the :if guard no longer checks for KITTY_PID since Sixel terminals are now supported too.

If you run into issues or have feature requests, open an issue on GitHub.

Release: v0.4.0 on GitHub

img img