Skip to content

Interactive echo demo

Click the terminal below and type a few lines. This widget runs the exact TypeScript module shown underneath, compiled against ghostty-webgpu’s built declarations and verified in headless Chromium on every build.

Hello from Ghostty. Type a line and press Enter.
  • Edit in place: use Left/Right arrows, Backspace, and Home/End before pressing Enter.
  • Browse history: press Up and Down arrows to recall previous lines, or Ctrl+C to cancel the current line.
  • Select and copy: drag across text to select, then press Cmd+C (macOS) or Ctrl+Shift+C (Linux/Windows).
  • Zoom font size: press Cmd+= / Cmd+- / Cmd+0 (or Ctrl equivalents on Linux/Windows) and watch the cell grid refit cleanly.
quick-start.ts
import { Terminal } from 'ghostty-webgpu'
import { attachTerminalHotkeys } from 'ghostty-webgpu/hotkeys'
import { readline, type ReadlineApi } from '@ghostty-webgpu/line-editor'
export async function mountEcho(host: HTMLElement) {
const terminal = await Terminal.create({ accessibility: {} })
attachTerminalHotkeys(terminal)
const editor = terminal.use(readline())
await terminal.open(host)
terminal.writeln('Hello from Ghostty. Type a line and press Enter.')
terminal.focus()
// Disposing the terminal rejects the pending read, which ends the loop.
echoLines(editor.api).catch(() => undefined)
return () => terminal.dispose()
}
async function echoLines(editor: ReadlineApi) {
for (;;) {
const result = await editor.read({ prompt: '$ ' })
if (result.kind === 'submit' && result.text) editor.print(result.text)
}
}

To replace @ghostty-webgpu/line-editor with a live Bash session over WebSocket, follow Connect a real shell.