cross-posted from: https://programming.dev/post/48790323
I'd like to announce ghostel, a terminal emulator for Emacs that uses libghostty-vt - the same VT parsing engine behind the Ghostty terminal - as a native Zig module.
It's inspired by vterm and follows the same general approach (native module does terminal emulation, Elisp handles the Emacs integration), but uses a more modern engine that supports newer terminal protocols. Ghostel is a superset of vterm's feature set - everything vterm can do, ghostel can too, plus a lot more on top.
Feature comparison with vterm
Feature ghostel vterm True color (24-bit) Yes Yes OSC 4/10/11 color queries Yes No Bold / italic / faint Yes Yes Underline styles (5 types) Yes No Underline color Yes No Strikethrough Yes Yes Cursor styles 4 types 3 types OSC 8 hyperlinks Yes No Plain-text URL/file detection Yes No Kitty keyboard protocol Yes No Mouse passthrough (SGR) Yes No Bracketed paste Yes Yes Alternate screen Yes Yes Shell integration auto-inject Yes No Prompt navigation (OSC 133) Yes Yes Elisp eval from shell Yes Yes TRAMP remote terminals Yes Yes OSC 52 clipboard Yes Yes Copy mode Yes Yes Drag-and-drop Yes No Auto module download Yes No Scrollback default ~5,000 1,000 PTY throughput (plain ASCII) 65 MB/s 29 MB/s Default redraw rate ~30 fps ~10 fps Key differences
Terminal engine. libghostty-vt comes from Ghostty, a modern GPU-accelerated terminal, and supports Kitty keyboard/mouse protocols, rich underline styles, and OSC 8 hyperlinks. libvterm targets VT220/xterm emulation and is more conservative in protocol support.
Mouse handling. Ghostel encodes mouse events (press, release, drag) and passes them through to the terminal via SGR mouse protocol. TUI apps like htop or lazygit receive full mouse input. vterm intercepts mouse clicks for Emacs point movement and does not forward them to the terminal.
Rendering. Both use text properties (not overlays) and batch consecutive cells with identical styles. Ghostel's engine provides three-level dirty tracking (none / partial / full) with per-row granularity. vterm uses damage-rectangle callbacks and redraws entire invalidated rows. Ghostel defaults to ~30 fps redraw; vterm defaults to ~10 fps.
Shell integration. Ghostel auto-injects shell integration scripts for bash, zsh, and fish - no shell RC changes needed. vterm requires manually sourcing scripts in your shell configuration. Both support Elisp eval from the shell and TRAMP-aware remote directory tracking.
Performance. In PTY throughput benchmarks (5 MB streamed through
cat, both backends configured with ~1,000 lines of scrollback), ghostel is roughly 2x faster than vterm on plain ASCII data (65 vs 29 MB/s). On URL-heavy output ghostel still comes out ahead (42 vs 24 MB/s); with link detection disabled ghostel reaches 65 MB/s regardless of input.Color auto-detection. Thanks to OSC 4/10/11 support, TUI programs like duf, btop, and delta can query Emacs for its foreground/background colors and automatically adapt to your light or dark theme - no
COLORFGBGhacks needed.Installation. Ghostel can automatically download a pre-built native module or compile from source with Zig. vterm uses CMake with a single C dependency (libvterm) and can auto-compile on first load from Elisp.
Installation
ghostel is available on MELPA:
(use-package ghostel :ensure t)Or with Emacs 30+ built-in
vc-use-package:(use-package ghostel :vc (:url "https://github.com/dakra/ghostel" :rev :newest))The native module is downloaded automatically on first use. If you prefer to build from source, you'll need Zig 0.15.2+.
Requires Emacs 27.1+ with dynamic module support on macOS or Linux.
Feedback, bug reports, and contributions very welcome.