Skip to content

Commit 146e7cd

Browse files
committed
Document prompt substitution and editor settings
1 parent c6c36df commit 146e7cd

1 file changed

Lines changed: 123 additions & 6 deletions

File tree

user_guide/41-terminal-recordings.qmd

Lines changed: 123 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ settings:
153153
idle_time_limit: 2.0 # Cap idle gaps to 2 seconds
154154
window_chrome: colorful # Window decoration style
155155
theme: monokai # Terminal color scheme
156+
font_family: "JetBrains Mono, Fira Code, monospace"
156157
font_size: 14 # Font size in rendered SVG (px)
157158
line_height: 1.2 # Line height multiplier
158159
padding: 12 # Inner padding (px)
160+
prompt: "" # Replace detected prompts with ❯
159161

160162
chapters:
161163
- at: 0.0
@@ -196,22 +198,107 @@ frames. All settings are optional and have sensible defaults.
196198
| `idle_time_limit` | `3.0` | Maximum seconds for any idle gap |
197199
| `window_chrome` | `colorful` | Window decoration: `colorful`, `plain`, `none` |
198200
| `theme` | (auto) | Terminal color scheme |
201+
| `font_family` | (system stack) | Font family for rendered SVG (comma-separated list) |
199202
| `font_size` | `14` | Font size in rendered SVG (px) |
200203
| `line_height` | `1.2` | Line height multiplier |
201204
| `padding` | `12` | Inner padding of the terminal area (px) |
205+
| `prompt` | (none) | Replacement character for detected prompts |
206+
| `prompt_pattern` | (none) | Regex pattern for prompt detection fallback |
202207

203208
These settings are applied at render time. Changing them requires re-rendering but not
204209
re-recording.
205210

211+
## Prompt Substitution
212+
213+
Terminal recordings often contain shell prompts that are visually noisy or environment-specific
214+
(e.g., `user@host:~/project $`). The **prompt substitution** feature lets you replace the
215+
prompt character in rendered output with a clean, consistent symbol.
216+
217+
### Configuration
218+
219+
Add `prompt` (and optionally `prompt_pattern`) to your script's `settings` block:
220+
221+
```yaml
222+
settings:
223+
prompt: "❯"
224+
```
225+
226+
This replaces detected prompt characters with `❯` in all rendered frames. Common replacement
227+
choices include `$`, `%`, `#`, `>`, `❯`, and `→`.
228+
229+
### How detection works
230+
231+
Prompt substitution uses a three-tier detection strategy, applied in order of precision:
232+
233+
1. **Structural detection** (most precise): If the recording contains input (`"i"`) events,
234+
the renderer correlates them with cursor position to identify exactly which rows have
235+
prompts and where the prompt character sits. This is fully automatic and requires no
236+
additional configuration.
237+
238+
2. **Pattern detection** (explicit): If you provide `prompt_pattern`, the renderer uses it as
239+
a regex to match prompt lines. The last character of the match is replaced. Use this when
240+
your recording lacks input events or when the structural detection doesn't match your
241+
prompt format:
242+
243+
```yaml
244+
settings:
245+
prompt: "$"
246+
prompt_pattern: '^\S+@\S+[^$]*\$ '
247+
```
248+
249+
3. **Heuristic detection** (automatic fallback): When neither input events nor a pattern are
250+
available, the renderer scans each row for lines that begin with a known prompt character
251+
(`$`, `%`, `#`, `>`, `❯`, `→`, etc.) followed by a space. This works well for simple
252+
prompt formats.
253+
254+
### Examples
255+
256+
Replace a verbose prompt with a minimal symbol:
257+
258+
```yaml
259+
settings:
260+
prompt: "❯"
261+
```
262+
263+
Before: `user@dev:~/project$ echo hello`\
264+
After: `❯ echo hello`
265+
266+
Use a regex for non-standard prompts:
267+
268+
```yaml
269+
settings:
270+
prompt: "$"
271+
prompt_pattern: '^\(venv\) .*\$ '
272+
```
273+
274+
This matches prompts like `(venv) user@host:~$ ` and replaces just the `$` character.
275+
276+
### Tips
277+
278+
Here are some practical guidelines for working with prompt substitution:
279+
280+
- start with just `prompt`: structural and heuristic detection handle most cases automatically
281+
- add `prompt_pattern` only if the default detection misidentifies prompt lines
282+
- the substitution affects rendered SVG frames only (the raw recording is never modified)
283+
- the Termshow Editor shows prompt substitution live in the preview, so you can see the
284+
effect immediately as you configure it
285+
286+
In most cases, a single `prompt` line in your settings block is all you need. The detection system
287+
is designed to do the right thing without manual tuning.
288+
206289
## Shortcode Reference
207290

208-
Embed a Termshow recording in any page with the `termshow` shortcode. At its simplest, you only
209-
need the `file` path:
291+
Embed a Termshow recording in any page with the `termshow` shortcode. At its simplest, you only need
292+
the `file` path:
210293

211294
```{shortcodes="false"}
212295
{{< termshow file="assets/my-demo" >}}
213296
```
214297

298+
The shortcode discovers the companion `.termshow.yml` script, renders the recording into SVG frames,
299+
and embeds everything inline during the build. No additional configuration or runtime fetches are
300+
required.
301+
215302
### Options
216303

217304
The shortcode accepts the following options to control player behavior:
@@ -253,6 +340,9 @@ Combine options freely. For instance, `autoplay` with `loop` creates a continuou
253340
demonstration, while `pause_on_chapters` with `speed="1.5"` produces a brisk but controlled
254341
tutorial.
255342

343+
The shortcode is the only integration point between your Quarto pages and the Termshow pipeline.
344+
Everything else (recording, scripting, rendering) happens automatically during the build.
345+
256346
## Player Controls
257347

258348
The embedded player provides interactive controls for navigating recordings. Here's what each
@@ -264,8 +354,8 @@ The bottom control bar contains (left to right):
264354

265355
1. **Play / Pause / Replay**: Toggles playback. Shows ↺ at the end of the recording.
266356
2. **Elapsed time**: Current playback position.
267-
3. **Timeline**: Click anywhere to seek. Gold chapter markers indicate chapter boundaries;
268-
their hit targets are wider than the visible marks for easy clicking.
357+
3. **Timeline**: Click anywhere to seek. Gold chapter markers indicate chapter boundaries; their hit
358+
targets are wider than the visible marks for easy clicking.
269359
4. **Remaining time**: Counts down to zero during playback.
270360
5. **Speed**: Cycles through 0.5×, 1×, 1.5×, 2×, 3×.
271361

@@ -468,7 +558,7 @@ the first one wins and subsequent ones are hidden.
468558
YAML to avoid backslash escape issues.
469559
- Use `label` to give context (e.g., "Install", "Build", "Test") so readers know what they're
470560
copying without reading the full snippet.
471-
- Snippets work regardless of playback state readers can copy while paused, playing, or at a
561+
- Snippets work regardless of playback state: readers can copy while paused, playing, or at a
472562
chapter stop.
473563

474564
## Importing Existing Recordings
@@ -608,6 +698,10 @@ scales up to fill it. The scaling recalculates on window resize and during drag.
608698
Above the terminal viewport, a **Chapter Title Bar** displays the currently active chapter name,
609699
simulating the window chrome appearance of the final player.
610700

701+
**Settings Button**: A small circular gear (⚙) button sits in the top-left corner of the
702+
Preview Area, next to the Info Button. Clicking it (or pressing `G`) toggles the **Settings
703+
Panel** described above.
704+
611705
**Info Button**: A small circular *i* button sits in the top-left corner of the Preview Area.
612706
Clicking it (or pressing `I`) toggles the **Info Panel**, a floating overlay showing recording
613707
metadata:
@@ -661,6 +755,28 @@ place to navigate without accidentally selecting or creating items.
661755

662756
A **Playhead** (white vertical line) spans all four tracks and moves with the current time.
663757

758+
### Global Settings Panel
759+
760+
The Termshow Editor includes a **Global Settings** panel for configuring global script settings
761+
visually. Click the gear icon (⚙) in the top-left corner of the Preview Area or press `G` to toggle
762+
it.
763+
764+
The Settings panel exposes the following controls:
765+
766+
| Control | Description |
767+
|---------|-------------|
768+
| **Default speed** | Playback speed multiplier (dropdown: 0.5×, 1×, 1.5×, 2×, 3×) |
769+
| **Idle limit** | Maximum idle gap in seconds (number with stepper buttons) |
770+
| **Chrome** | Window decoration style (dropdown: colorful, simple, none) |
771+
| **Font family** | Comma-separated font stack for rendered output |
772+
| **Prompt** | Replacement character for prompt substitution, with preset buttons (`$` `%` `#` `>` `❯` `→`) |
773+
| **Pattern** | Regex pattern for prompt detection (see [Prompt Substitution]) |
774+
775+
All changes apply immediately to the live preview so you can see the effect of each setting in real
776+
time. Settings are saved to the `settings` block of the `.termshow.yml` file when you press Save.
777+
778+
Press `Escape` or click outside the panel to dismiss it.
779+
664780
### Properties Panel
665781

666782
Clicking any item in the timeline opens the **Properties Panel** on the right side. All fields
@@ -724,12 +840,13 @@ The Termshow Editor supports these keyboard shortcuts for efficient editing:
724840
| `A` | Add annotation at playhead |
725841
| `X` | Add cut at playhead |
726842
| `D` | Add snippet at playhead |
843+
| `G` | Toggle global settings panel |
727844
| `I` | Toggle info panel |
728845
| `←` / `→` | Seek ±1 second (or nudge active edge ±10ms) |
729846
| `[` / `]` | Jump to previous / next chapter |
730847
| `Y` | View YAML |
731848
| `Delete` / `Backspace` | Delete selected item |
732-
| `Escape` | Close properties panel, deselect |
849+
| `Escape` | Close settings/properties panel, deselect |
733850
| `Cmd+S` / `Ctrl+S` | Save |
734851

735852
### Unsaved Changes

0 commit comments

Comments
 (0)