Xpty
xterm.js and node-pty for react and electron
Install / Use
/learn @loopmode/XptyREADME
@loopmode/pty
A react component and some helpers for building terminals in electron apps.
Based on xterm and node-pty.
Usage
There are two parts to this:
- A child process that is managed by node-pty and
- a view that is managed by xterm.
Creating a child process
import { PtyManager, createCommand } from '@loopmode/xpty';
const command = createCommand({
cmd: 'ls -lah',
cwd: '~'
});
const ptyProcess = PtyManager.connect(command);
If you do not want to immediatly execute the command, pass false as second argument.
The returned object is an pty.IPty instance.
Rendering a view
Basically, you render the XTerminal component and pass a ptyProcess prop to it.
import React from 'react';
import { XTerminal } from '@loopmode/xpty';
export const Example = ({ ptyProcess }) => {
return (
<XTerminal ptyProcess={ptyProcess}>
)
}
TODO
- hook, e.g.
usePty, to get aptyProcesseasily - docs for existing features and props
- more features and props
- tests
Related Skills
node-connect
338.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.6kCommit, push, and open a PR
