Connect a terminal
Wire a terminal component to a Startpod shell process.
Start a shell with an initial terminal size:
const shell = await startpod.spawn("jsh", [], {
terminal: { cols: terminal.cols, rows: terminal.rows },
})jsh and bash use Startpod's browser shell implementation. They are useful for project navigation and supported shell commands, but they do not reproduce every desktop shell feature.
Connect output and input
const output = shell.output.getReader()
const input = shell.input.getWriter()
void (async () => {
for (;;) {
const { value, done } = await output.read()
if (done) break
terminal.write(value)
}
})()
terminal.onData((data) => {
void input.write(data)
})Forward resizes
terminal.onResize(({ cols, rows }) => {
shell.resize?.({ cols, rows })
})When the terminal closes, release its streams and call shell.kill().