a81956338263b3a1c25b69b328a84d0f87db4fde
Ghostty Web
基于 Web 的终端模拟器,使用 xterm.js 渲染和 node-pty 提供 PTY 支持。
当前状态
✅ 基础功能已完成
- WebSocket + PTY 服务器 (Node.js)
- xterm.js 终端渲染 (支持 WebGL)
- Ghostty 风格 UI
- 跨平台支持 (Windows/macOS/Linux)
⏳ WASM 集成待完成
- libghostty-vt 源码已克隆到
lib/ghostty/ - 需要安装 Zig 0.13+ 编译为 WebAssembly
- WASM 加载框架已就绪 (
src/frontend/ghostty-vt.js)
快速开始
cd ghostty-web
npm install
npm start
然后打开浏览器访问: http://localhost:3000
安装 Zig (用于编译 WASM)
Windows:
winget install Ziglang.Zig
macOS:
brew install zig
Linux:
wget https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz
tar -xf zig-linux-x86_64-0.13.0.tar.xz
sudo mv zig-linux-x86_64-0.13.0 /opt/zig
编译 libghostty-vt WASM
# macOS/Linux
./scripts/build-wasm.sh
# Windows PowerShell
./scripts/build-wasm.ps1
项目结构
ghostty-web/
├── package.json
├── README.md
├── Dockerfile
├── docs/
│ └── WASM_BUILD.md # WASM 编译详细指南
├── lib/
│ └── ghostty/ # ghostty 源码 (含 libghostty-vt)
├── scripts/
│ ├── build-wasm.sh # Linux/macOS 构建脚本
│ ├── build-wasm.ps1 # Windows PowerShell 构建脚本
│ └── install-zig.sh # Zig 安装脚本
└── src/
├── backend/
│ └── server.js # WebSocket + PTY 服务器
└── frontend/
├── index.html # 主页面
├── styles.css # Ghostty 风格样式
└── ghostty-vt.js # WASM 加载器
架构
┌─────────────────────────────────────────────────────────────┐
│ 浏览器 │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ xterm.js (终端渲染 + 输入处理) │ │
│ │ ghostty-vt.js (WASM 加载器,待集成) │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ WebSocket │
└────────────────────────────┼────────────────────────────────┘
│
┌────────────────────────────▼────────────────────────────────┐
│ 后端服务器 │
│ ┌──────────────────┐ ┌───────────────────────────┐ │
│ │ WebSocket Server │ ◄─── │ node-pty (PTY 进程) │ │
│ │ (ws library) │ │ bash/powershell │ │
│ └──────────────────┘ └───────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
功能
- ✅ 跨平台 PTY 支持
- ✅ WebGL 加速渲染
- ✅ 终端大小调整
- ✅ 新标签页
- ✅ 全屏模式
- ✅ 自定义外观 (Ghostty 风格深色主题)
环境变量
PORT- 服务器端口 (默认: 3000)
License
MIT
Description
Languages
HTML
52%
JavaScript
22.7%
CSS
14.4%
Shell
5.5%
PowerShell
5.1%
Other
0.3%