1. Import the shell
The $ tag is exported from "bun" and runs shell commands cross-platform with no extra dependency.
import { $ } from "bun";Typorithm · medium
Step 1 of 8 · intro card
System & FFI
Bun Shell exports a $ tag from "bun" that runs shell commands cross-platform. Await $`cmd`.text() to capture stdout, use .quiet() to silence it, and rely on auto-escaped ${interpolation}. Pipes and redirects work without a real system shell.
import { $ } from "bun" gives you a tagged-template shell: await $`ls -la` runs the command, and the same code works on macOS, Linux, and Windows because Bun parses the script itself.
Chain .text() to get stdout as a string or .quiet() to run silently; values you interpolate with ${} are automatically escaped, so user input never breaks out into shell injection.
Familiar shell features carry over — pipe with |, redirect with > — but they are implemented by Bun rather than handed to /bin/sh, keeping behaviour consistent across platforms.
import { $ } from "bun"; await $`cmd` runs a command.
.text() captures stdout; .quiet() silences output.
${interpolation} is auto-escaped against injection.
import { $ } from "bun";
const files = await $`ls -la`.text();
const name = "my file.txt";
await $`cat ${name}`.quiet();
await $`echo hello | grep h > out.txt`;Connect each part of the code to the concept before you type.
The $ tag is exported from "bun" and runs shell commands cross-platform with no extra dependency.
import { $ } from "bun";Awaiting $`...`.text() runs the command and resolves to its stdout as a string.
const files = await $`ls -la`.text();Interpolated ${values} are auto-escaped, so a filename with spaces is passed as a single safe argument.
await $`cat ${name}`.quiet();.quiet() runs the command without echoing its output to the terminal.
.quiet()Pipes (|) and redirects (>) work just like a real shell, but cross-platform via Bun's own parser.
await $`echo hello | grep h > out.txt`;Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.