blog.dopana

Back

libghostty là thư viện embeddable terminal từ Ghostty — terminal emulator nổi tiếng viết bằng Zig của Mitchell Hashimoto (người sáng lập HashiCorp).

App của bạn → libghostty → Terminal emulation
              C API, zero-dep
plaintext

Không phải tự viết parser VT, không xterm.js, không libvte. Một thư viện C duy nhất, không phụ thuộc gì — nhúng vào app nào cũng được.

Vấn Đề#

Trước libghostty, mỗi app cần terminal đều tự làm theo cách riêng:

  • IDE (VS Code, JetBrains) → xterm.js / jediterm
  • Terminal app → tự viết VT parser
  • Web console (GitHub Actions, Vercel) → parse ANSI thủ công, sai đủ kiểu
  • SSH client → mỗi app một kiểu

Kết quả: hàng trăm implementation terminal không đầy đủ, chậm, bug.

libghostty-vt#

Thư viện đầu tiên trong họ libghostty: zero-dependency, parse terminal sequence, maintain terminal state (cursor, style, wrapping…).

Zig core → C API → Bindings (Go, Rust, Python, .NET, TS, ...)

           App của bạn
plaintext

Đặc điểm:

  • SIMD-optimized parsing
  • Unicode đầy đủ
  • Kitty Graphics Protocol, Tmux Control Mode
  • Fuzz + Valgrind tested
  • Không cần libc — portable khắp nơi
  • WASM target — chạy trong browser

Ecosystem#

Từ khi ra mắt (9/2025), cộng đồng đã xây dựng 80+ project trên libghostty.

Bindings — Nhúng Vào Mọi Ngôn Ngữ#

// Go — mitchellh/go-libghostty
import "github.com/mitchellh/go-libghostty"

vt := libghostty.New()
vt.Write([]byte("\x1b[31mHello\x1b[0m"))
fmt.Println(vt.Cell(0, 0).Value) // "Hello"
go
// Rust — Uzaaft/libghostty-rs
use libghostty_rs::VirtualTerminal;

let mut vt = VirtualTerminal::new(80, 24);
vt.write(b"\x1b[32mGreen text\x1b[0m");
println!("{}", vt.cell(0, 0).unwrap().character()); // "G"
rust
// .NET — deblasis/libghostty-vt-dotnet
using LibGhosttyVt;

var vt = new VirtualTerminal(80, 24);
vt.Write("\e[34mBlue\e[0m");
Console.WriteLine(vt.GetCell(0, 0).Char); // "B"
csharp
# Python — luckydonald/ghosttpy-vt
from ghosttpy_vt import VirtualTerminal

vt = VirtualTerminal(80, 24)
vt.write(b"\x1b[33mYellow\x1b[0m")
print(chr(vt.cell(0, 0).char))  # "Y"
python

Bindings hiện có: Go, Rust, C++, Python, .NET, TypeScript, Dart (Flutter), Odin, Elixir, MoonBit, Node.js, Swift (SwiftPM).

Terminal App — Hàng Loạt Terminal Mới#

Vì libghostty xử lý VT core, dev chỉ cần làm UI:

  • conterm — macOS terminal (SwiftUI)
  • macterm — macOS terminal lightweight (SwiftUI)
  • fantastty — macOS terminal với workspace, notes, live tab preview
  • Forge — macOS terminal multiplexer cho AI agents
  • Muxy — macOS terminal multiplexer (SwiftUI)
  • deepin-terminal-ghostty — Deepin Terminal cho Linux
  • footty — foot + libghostty (Wayland)
  • forgetty — GTK4 terminal cho Linux (daemon architecture)
  • Husk — Wayland terminal C++ nhẹ
  • monstar — Wayland terminal nhỏ
  • Dotty — .NET terminal cross-platform
  • mightty — Windows terminal (experimental)
  • phantty — Windows renderer
  • tildaz — Quake-style dropdown terminal (Windows + macOS)
  • Umbra — Android terminal GPU-accelerated
  • Chuchu — Android SSH client
  • ghosttyfx — JavaFX terminal
  • gostty — Go terminal (Ebitengine)
  • hollow — Zig terminal + LuaJIT

Mỗi app chỉ cần focus vào UI + tính năng riêng, còn terminal logic đã có libghostty.

SSH & Remote Clients#

  • Echo — SSH/Mosh client iOS/iPadOS
  • Geistty — SSH terminal iOS (Metal rendering)
  • Quay — macOS connection manager SSH/SFTP
  • remux — iOS tmux client
  • Spectty — SSH/Mosh iOS nhanh
  • VVTerm — SSH iOS/iPad/macOS (iCloud sync, voice-to-command)
  • NeoShell — iPad remote workspace
  • RootShell — terminal cho Apple platforms

Web & Embedded#

  • ghostty-web — Ghostty cho web (xterm.js API compatible, bởi coder.com)
  • browstty — Zig WASM module chạy libghostty trong browser
  • electron-libghostty — libghostty trong Electron
  • vscode-bootty — VS Code terminal extension (WASM)
  • obsidian-ghostty-terminal — Obsidian plugin
  • jupyterlab-ghostty-terminal — JupyterLab extension
  • Restty — Web terminal library (WebGPU + text-shaper)
  • webterm — Web terminal server dashboard
  • RemoteTTYs — Remote terminal từ browser (không cần mở port)

AI Agent Ecosystem#

Đây là mảng phát triển nhanh nhất. AI coding agents (Claude Code, OpenCode, Codex) cần terminal để chạy lệnh — và các app đang dùng libghostty để xây workspace cho agents:

  • Mux (coder.com) — Desktop + browser app cho isolated agentic development
  • Ghostree — Ghostty fork với git worktree + AI agents support
  • AiyuTerm — macOS terminal workspace với multi-repo sidebar, split layouts, SSH, real-time AI agent status
  • Mux0 — macOS terminal với live status cho Claude Code, OpenCode, Codex
  • cmux — macOS terminal với vertical tabs + notifications cho AI agents
  • moss — macOS workspace orchestrating AI agents với multi-terminal canvas
  • Supacode — macOS command center chạy agents song song
  • limpid — macOS terminal cho kỷ nguyên AI agent
  • blink — AI terminal hiện đại
  • Zentty — macOS terminal cho agentic development (workspaces, notifications)
  • in0 — macOS terminal multiplexer với live AI agent status
  • agtmux-term — AI-agent-aware terminal (SwiftUI sidebar)
  • wispterm — Cross-platform workspace cho AI agents
  • paulatty — AI agent team workspace
  • ADHDev — Self-hosted control plane cho AI coding agents
  • moai-studio — Rust agent IDE (GPUI, libghostty-vt)
  • witty — AI terminal (Python + Qt6 + Rust)
  • YEN — Terminal-first IDE (speech-to-text, themes, notifications)
  • Factory Floor — macOS workspace cho parallel development + git worktrees + Claude Code
  • TheCommander — macOS AI workspace (diff review, git workflow)
  • codelima — Run coding agents trong VM sandbox cô lập
  • Aizen — macOS workspace cho parallel development
  • taskers — Agent-first terminal workspace (Rust shell, Niri-like tiling)
  • frep — Agentic terminal emulator

AI agent tools là mảng phát triển nóng nhất trên libghostty.

System Utilities#

  • evp — Terminal recorder (Rust)

  • headless-terminal — Puppeteer cho TUI (vim, emacs, htop)

  • findr — File manager macOS với embedded terminal

  • OmniWM — macOS tiling WM với Ghostty-powered quake terminal

  • Ribari — Niri-inspired web browser macOS + libghostty

  • hauntty — Terminal session persistence (WASM)

  • vanish — Terminal session multiplexer nhẹ

  • Zmx — Session persistence cho terminal processes

  • term2html — ANSI → HTML converter

  • Trolley — Terminal runtime cho TUI apps

  • vterm-mcp — MCP server để drive/test TUI apps

  • OrbStack — Docker nhẹ trên macOS (built-in Ghostty terminal)

  • reed — Terminal file viewer (syntax highlight, inline images, Mermaid)

  • Hot Notes — macOS Notes fuzzy search

  • mdnb — macOS Markdown editor + embedded Ghostty terminal

  • pynb — macOS Jupyter notebook + Ghostty terminal

  • shade — Neovim-centric Swift library

  • emacs-libgterm — Terminal emulator cho Emacs

  • Ghostel — Terminal emulator cho Emacs (true color, OSC 8, Kitty keyboard)

  • it-shell3 — Terminal multiplexer với CJK input support

Tại Sao Lại Bùng Nổ?#

3 lý do chính:

1. Zero Dependency#

// Chỉ cần include header + link lib
#include <ghostty/vt.h>

ghostty_vt_t* vt = ghostty_vt_new(80, 24);
ghostty_vt_write(vt, "\e[31mRed text\e[0m");
const char* text = ghostty_vt_get_text(vt, 0, 0, 80, 24);
c

Không runtime, không framework, không libc. Portable: macOS, Linux, Windows, WASM.

2. Correctness#

libghostty-vt kế thừa core từ Ghostty — đã được test hàng năm trên hàng triệu người dùng. SIMD-optimized, fuzz-tested, hỗ trợ đầy đủ Kitty Graphics Protocol, Tmux Control Mode, Unicode.

So sánh với tự viết hoặc dùng thư viện khác:

Tính năngTự viếtxterm.jslibvtelibghostty
ANSI color
RGB color (12 formats)
Kitty protocol
Tmux control mode
Unicode⚠️
SIMD
Zero dependency
C API
WASM

3. C API = Universal#

C API có nghĩa là bindings cho mọi ngôn ngữ: Go, Rust, Python, .NET, TypeScript, Dart, Odin, Elixir, MoonBit, Node.js, Swift. Cộng đồng đã tự xây bindings cho ngôn ngữ họ dùng — không cần chờ team Ghostty.

Tương Lai#

Mitchell Hashimoto đã công bố lộ trình: libghostty-vt chỉ là bước đầu. Tiếp theo sẽ là:

  • Input handling — keyboard encoding (lĩnh vực đầy rẫy edge case)
  • GPU rendering — cung cấp OpenGL/Metal surface, libghostty render terminal
  • GTK widgets + SwiftUI framework — terminal view trọn gói

Hệ sinh thái terminal đang thay đổi. Ghostty không chỉ là terminal app — nó là nền tảng.

# Xu hướng: terminal là component, không phải monolithic app
Before: Terminal app tự viết VT parser
After:  App của bạn libghostty (C API, zero-dep)
bash

80+ project trong 9 tháng. AI agents, SSH clients, IDE plugins, web terminals — tất cả đều embed terminal từ một thư viện chung. Đây là hướng đi đúng cho hệ sinh thái terminal.

Tài liệu tham khảo#