The jslab CLI
Open files and piped code in JSLab from a terminal with the jslab command, and run them straight away.
jslab is a small command-line tool that opens files, or code piped from another command, in a new JSLab tab.
Install it
Open files in JSLab from a terminal, or pipe code into a new tab and run it.
Choose Help → Install jslab Command… to link the jslab binary inside the app (Contents/Resources/app/bin/jslab) into ~/.local/bin/jslab.
If ~/.local/bin isn’t on your PATH, the message tells you the line to add to your shell profile:
export PATH="$HOME/.local/bin:$PATH"
Once it’s installed, the same menu item reads Uninstall jslab Command…, which removes the link.
Usage
jslab [file ...] Open files in new tabs
jslab - Read code from stdin into a new tab
jslab --run [file|-] Open and run immediately
--runtime bun|browser|browser-node
--lang ts|js|tsx|jsx (default: from extension, else settings)
--cwd <dir> Set the tab's working directory (default for `-`: current dir)
--title <title>
jslab --version | --help
| Option | What it does |
|---|---|
--run |
Runs the code as soon as it opens. Without it, the file only opens. |
--runtime |
The tab’s runtime: bun, browser or browser-node (Browser & Node APIs). |
--lang |
The tab’s language. By default it comes from the file’s extension, or from your settings. |
--cwd |
The tab’s working directory. For jslab -, it defaults to your terminal’s current folder. |
--title |
The tab’s title. |
Examples
# Open a file in a new tab
jslab notes.ts
# Run code piped from stdin
echo 'console.log(new Date())' | jslab --run -
# Open a component in the Browser runtime, in the current folder
jslab --runtime browser --cwd . app.tsx
How it works
If JSLab isn’t running, jslab starts it and waits up to 10 seconds for it to be ready. Each call then sends one request over a local socket, jslab.sock in JSLab’s data folder. See Troubleshooting for where that is.