Terminal
A command and what came back: the prompt and the command highlighted as shell, its output, and a line that says whether it is running, done or failed.
pnpm typecheck> tsc --noEmit
pnpm lint --max-warnings 0app/page.tsx 12:7 error 'user' is assigned a value but never used
Installation
npx shadcn@latest add "@aiellie/terminal"shadcn needs the @aiellie registry in components.json first. npx aiellie add terminal adds it on its first run, then installs the same way.
Terminal shows a run rather than a line to run: the command after its prompt, coloured as shell, what it printed, and a status line saying whether it's running, finished, or failed with its exit code. It goes inside a CodeBlock, so the frame, title and copy work as they do for code.
Getting started
Show a run
components/run.tsximport { CodeBlock, CodeBlockHeader, CodeBlockTitle, } from "@/components/aiellie/code-block" import { TerminalCommand, TerminalContent, TerminalOutput, TerminalStatus, } from "@/components/aiellie/terminal" export function Run({ command, output, exitCode, }: { command: string output: string exitCode: number | null }) { return ( <CodeBlock> <CodeBlockHeader> <CodeBlockTitle icon={null}>Terminal</CodeBlockTitle> </CodeBlockHeader> <TerminalContent> <TerminalCommand>{command}</TerminalCommand> <TerminalOutput tone={exitCode ? "error" : "default"}> {output} </TerminalOutput> <TerminalStatus status={exitCode === null ? "running" : exitCode ? "error" : "success"} exitCode={exitCode ?? undefined} /> </TerminalContent> </CodeBlock> ) }
Anatomy
<div data-slot="terminal-content" dir="ltr">
<div data-slot="terminal-command" /> {/* $ pnpm build */}
<pre data-slot="terminal-output" data-tone="default | error" />
<div data-slot="terminal-status" data-status="running | success | error" />
</div>The prompt is left out of a selection, so a copied command pastes as a command. Several runs stack in one TerminalContent, each new command set a little apart from the run before.
The status mark is the Status dot: live and pulsing while it runs, then success or destructive, always with a word beside it.
Examples
While it runs
Append output as it arrives and keep the status on running until the command exits.
pnpm vitest runYour own prompt
<TerminalCommand prompt="~/app ❯">pnpm dev</TerminalCommand>API reference
TerminalCommand
| Prop | Type | Default | Description |
|---|---|---|---|
children | string | required | What was typed. |
prompt | string | "$" | The mark before it, left out of a copy. |
All other div props are forwarded.
TerminalOutput
| Prop | Type | Default | Description |
|---|---|---|---|
tone | "default" | "error" | "default" | error sets the output in the destructive ink. |
All other pre props are forwarded.
TerminalStatus
| Prop | Type | Default | Description |
|---|---|---|---|
status | "running" | "success" | "error" | required | Where the run is. |
exitCode | number | Said after a failure, like "Exited with 1". | |
children | ReactNode | Words of your own in place of "Running", "Done" or the exit code. |
All other div props are forwarded.