Ghostel.el:由 libghostty 驱动的终端模拟器
Ghostel.el: Terminal emulator powered by libghostty

原始链接: https://dakra.github.io/ghostel/

本次比较评估了三款 Emacs 终端模拟器:**Ghostel**(基于 `libghostty-vt`)、**vterm** 和 **eat**。 **Ghostel** 是最先进的选择,它利用高性能的 Zig/C 原生引擎,支持 Kitty 图形协议、键盘协议、自动 Shell 集成以及智能密码提示检测等现代特性。其运行速度显著优于其他两者。 **vterm** 是一款稳定且经过原生编译的方案。虽然其性能优于纯 Elisp 实现,但缺乏对现代图形(如 Sixel 或 Kitty 协议)的支持,且鼠标处理较为受限,更侧重于 Emacs 集成而非终端交互。 **Eat** 的特点在于它是纯 Emacs Lisp 实现,因此具有最好的可移植性和最简便的安装方式。但代价是性能显著降低,且不支持高级协议。 综上所述,**Ghostel** 通过利用现代原生技术,提供了最出色的功能集与性能;**vterm** 依然是一个成熟、均衡的原生选择;而对于需要纯 Emacs 原生环境、且不希望有外部依赖或编译需求的用户来说,**eat** 是最容易上手的选择。

```Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Ghostel.el:由 libghostty 驱动的终端模拟器 (dakra.github.io) 19 点,由 signa11 发布于 3 小时前 | 隐藏 | 过往 | 收藏 | 讨论 帮助 准则 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索: ```
相关文章

原文

Terminal engine. libghostty-vt comes from Ghostty, a modern GPU-accelerated terminal, and is the only one of the three to support the Kitty keyboard and graphics protocols, five underline styles, OSC 8 hyperlinks, OSC 4/10/11 color queries, and DEC 2026 synchronized output. libvterm targets VT220/xterm emulation and is the most conservative - no faint text, single underline only, no images. eat sits in between: true color, faint, colored underlines, and even Sixel images, but none of the Kitty protocols, OSC 8, or desktop notifications.

Packaging and installation. eat's headline advantage is that it is pure Emacs Lisp: nothing to compile or download, so it runs anywhere Emacs does - including hosts where you cannot build a native module. Ghostel downloads a prebuilt module on first use (or builds it with Zig); vterm compiles its single C dependency with CMake on first load. The native engines are what buy ghostel and vterm their large throughput margin over eat.

Graphics. Inline images work in ghostel via the Kitty graphics protocol and in eat via Sixel; vterm has neither. The two protocols are not interchangeable - a program emitting Kitty graphics shows nothing in eat, and vice versa.

Mouse handling. Ghostel and eat both encode mouse events (press, release, drag) and forward them to the child program over the SGR protocol, so TUIs like htop or lazygit receive real mouse input. vterm instead intercepts mouse clicks for Emacs point movement and does not forward them to the terminal.

Input modes. The char / semi-char / Emacs / line model originates in eat; ghostel adopts the same design, with five modes selected from one base keymap (see Input modes). vterm has only its default mode (≈ semi-char) plus vterm-copy-mode. Line mode - buffer the in-progress line for full Emacs editing and send it atomically with RET - exists in ghostel and eat but not vterm. The copy/Emacs split differs too: ghostel and vterm have a copy mode that freezes output so you can select against a stable snapshot, whereas eat's read-only "Emacs mode" stays live. Ghostel offers both a freezing copy mode and a live read-only Emacs mode.

Shell integration. Ghostel auto-injects integration for bash, zsh, and fish - no RC changes needed. vterm and eat both ship integration scripts but require you to source them yourself. All three track the working directory (over TRAMP too) and navigate between prompts - ghostel via OSC 133, vterm and eat via their own OSC 51-based annotations. Ghostel and vterm additionally let the shell evaluate whitelisted Elisp; eat exposes a fixed set of UI commands rather than arbitrary eval.

Password prompts. Ghostel detects when the foreground program is reading a password (sudo, ssh, gpg, …) and prompts via read-passwd, sending the answer down the PTY without routing keystrokes through Emacs's key pipeline; a hook can also satisfy known prompts from auth-source (see Password prompt detection). eat has a manual eat-send-password but does not detect prompts automatically. vterm has no interception at all - each character is a normal keypress that lands in view-lossage, the recent-keys ring, and anything else watching input.

Input methods. Ghostel and vterm forward Emacs input methods into the terminal (ghostel via ghostel-ime-mode); eat does not.

Rendering. All three use text properties rather than overlays. Ghostel uses libghostty's row dirtiness plus cursor tracking to update only the rows that need to change, and defaults to ~30 fps; vterm uses damage-rectangle callbacks and defaults to ~10 fps; eat coalesces output within an 8-33 ms latency window.

Performance. On the cross-emulator benchmark (1 MB streamed, ~1,000 lines of scrollback, Emacs 32.0.50), ghostel leads plain-ASCII throughput at ~75 MB/s - roughly 4x vterm (~18) and 12x eat (~6), with Emacs's built-in term landing near eat (~7). eat pays for being pure Elisp. Ghostel's clickable-link detection does real work on URL- and path-dense output and roughly halves its throughput there (still ahead of the rest); it is free on ordinary output and can be disabled. For local shells ghostel's native PTY path is faster still - see Performance for the full numbers.

For a detailed architectural comparison, see the Architecture section.

联系我们 contact @ memedata.com