A react component and some helpers for building terminals in electron apps.
Based on xterm and node-pty.
There are two parts to this:
- A child process that is managed by node-pty and
- a view that is managed by xterm.
import{PtyManager,createCommand}from'@loopmode/xpty';constcommand=createCommand({cmd: 'ls -lah',cwd: '~'});constptyProcess=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.
Basically, you render the XTerminal component and pass a ptyProcess prop to it.
importReactfrom'react';import{XTerminal}from'@loopmode/xpty';exportconstExample=({ ptyProcess })=>{return(<XTerminalptyProcess={ptyProcess}>
)
}- hook, e.g.
usePty, to get aptyProcesseasily - docs for existing features and props
- more features and props
- tests