# Shell & Node

> An interactive bash with pipes, background jobs and Node.js, and no install step, so it is ready in a second.

Live: https://clientvm.joeldsouza.me/demos/shell/ (Chromium) · Source: https://github.com/Reflex-Gravity/client-vm/blob/main/site/src/demos/shell.ts

A real interactive bash on a pseudo-terminal: line editing, history, Tab completion, Ctrl+C, and job control with Ctrl+Z, fg and bg. The Linux commands are written in TypeScript and checked against bash and the GNU tools.

Start node serve.js in the background and its page shows in the preview while the prompt stays free for curl.

## How it's built

```ts
import { attachShell } from '@clientvm/terminal';

const box = await vm.createInstance({ fs: { from: projectFiles } });
await attachShell(term, box, { cwd: '/home/user/app' });
```

## Try

- versions: `uname -sr && node -v && npm -v`
- pipe a CSV: `tail -n +2 sales.csv | cut -d, -f2 | sort | uniq -c | sort -rn`
- run node: `node fib.js 30`
- serve in background: `node serve.js &`
- curl it: `curl -s localhost:8080/api/summary`
- list jobs: `jobs`
- find & count: `find . -name '*.js' | xargs wc -l`

## Built with

bash, coreutils, Node.js 24, git

## Docs

- [Terminals and signals](https://clientvm.joeldsouza.me/docs/decisions/0017-pty-and-signals/)
- [Shell commands](https://clientvm.joeldsouza.me/docs/decisions/0011-in-process-shell-commands/)
