Skip to content

Echo terminal

The terminal below prints a greeting and echoes its input. Click it and type. Its source is the checked mountEcho module from the quick start.

Hello from Ghostty. Type here to echo your keys.
quick-start.ts
import { Terminal, attachTerminalHotkeys } from 'ghostty-webgpu'
export async function mountEcho(host: HTMLElement) {
const terminal = await Terminal.create({ accessibility: {} })
const { r, g, b } = terminal.appearance.theme.background
host.style.backgroundColor = `rgb(${r}, ${g}, ${b})`
attachTerminalHotkeys(terminal)
await terminal.open(host)
terminal.writeln('Hello from Ghostty. Type here to echo your keys.')
terminal.onData((bytes) => terminal.write(bytes))
terminal.focus()
return () => terminal.dispose()
}

Connect a PTY to replace the echo with shell output. The landing page shell runs entirely in the browser.