Skip to content

Commit 0d20270

Browse files
tigclaude
andcommitted
docs: add tuirec recording guidance + ocgv/shot/F7 demo GIFs
Add Scripts/tuirec/ — a PSTui-specific recording guide modeled on Terminal.Gui's Scripts/tuirec/README.md, plus three demo scripts driven by tuirec: - demo-ocgv.ps1 -> hero.gif: 'ls | ocgv' then the killp process picker - demo-shot.ps1 -> shot.gif: Get-Process | shot tree exploration (-FullScreen) - demo-f7.ps1 -> f7history.gif: the F7 command-history picker Embed the GIFs in the README (hero up top, shot in Features, F7 in the command- history section) and drop the old 1.8 MB ocgv.gif (hero.gif is ~120 KB). The guide documents the PSTui-specific gotchas: record a -File script (not -Command, since --args is comma-split), the pwsh REPL doesn't render under a recording PTY (so demos invoke the cmdlet directly), -Focus Filter for live ocgv filtering, and -FullScreen for a clean shot capture. artifacts/ is git-ignored; committed GIFs live in docs/PSTui/. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6347a19 commit 0d20270

10 files changed

Lines changed: 185 additions & 1 deletion

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ publish/
1313
Properties/launchSettings.json
1414
nuget.local.config
1515
GraphicalTools.Dev.slnx
16+
artifacts/

‎README.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ It's part of the [tui-cs](https://github.com/tui-cs) family, alongside
2727
[Terminal.Gui](https://github.com/tui-cs/Terminal.Gui),
2828
[clet](https://github.com/tui-cs/clet), and [cli](https://github.com/tui-cs/cli).
2929

30+
![ls | ocgv and killp](docs/PSTui/hero.gif)
31+
32+
> `ls | ocgv` then a `killp` process picker — interactive, filterable tables
33+
> straight from the pipeline.
34+
3035
## Installation
3136

3237
Requires **PowerShell 7.6+** (the binary module targets .NET 10). Works on
@@ -95,7 +100,9 @@ Install-Module PSTui
95100
* Multiple Selection - Select multiple items and send them down the pipeline.
96101
* Customizable - Customize the grid view window with the built-in parameters.
97102

98-
![Demo GIF](docs/PSTui/ocgv.gif)
103+
**`Show-ObjectTree` (`shot`)** — explore any object graph as an interactive tree:
104+
105+
![Get-Process | shot](docs/PSTui/shot.gif)
99106

100107
## Examples
101108

@@ -212,6 +219,8 @@ PSTui includes a graphical command-history picker — the
212219
[F7History](https://github.com/tui-cs/F7History) module, **folded in and enabled
213220
by default** — no separate package to install.
214221

222+
![F7 command history](docs/PSTui/f7history.gif)
223+
215224
> **The key bindings register when PSTui is imported.** `Install-Module` alone
216225
> does *not* bind `F7`; PowerShell only loads the module (and its key handlers)
217226
> on `Import-Module`. To have `F7`/`Shift+F7` available in **every** session, add

‎Scripts/tuirec/README.md‎

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Recording PSTui GIFs with `tuirec`
2+
3+
Use this guide to (re)generate the animated GIFs in the README and docs. The
4+
recorder is [`tui-cs/tuirec`](https://github.com/tui-cs/tuirec) — a Go CLI that
5+
spawns a process in a PTY, injects keystrokes, records an asciinema cast, and
6+
renders a GIF via `agg`. This is the PSTui-specific companion to
7+
[Terminal.Gui's `Scripts/tuirec/README.md`](https://github.com/tui-cs/Terminal.Gui/blob/main/Scripts/tuirec/README.md);
8+
read that for the full keystroke-token reference.
9+
10+
## Install
11+
12+
```bash
13+
# Requires Go 1.22+. agg is auto-downloaded on first use.
14+
go install github.com/tui-cs/tuirec/cmd/tuirec@latest
15+
export PATH="$(go env GOPATH)/bin:$PATH" # tuirec installs to GOPATH/bin
16+
tuirec --version
17+
```
18+
19+
## How PSTui differs from recording a Terminal.Gui app
20+
21+
PSTui cmdlets are driven from a **PowerShell pipeline**, not a `ScenarioRunner`
22+
DLL. Two consequences shape every recipe here:
23+
24+
1. **Record a script file, not `-Command`.** `tuirec --args` is **comma-split**,
25+
and PowerShell pipelines are full of commas (`Select-Object a, b, c`). So the
26+
demos live in small `*.ps1` files in this folder and are run with `-File`:
27+
28+
```bash
29+
--binary pwsh --args "-NoLogo,-NoProfile,-File,./Scripts/tuirec/demo-ocgv.ps1"
30+
```
31+
32+
2. **The pwsh REPL does not render under a recording PTY** — only the
33+
Terminal.Gui app it launches does. So you cannot record "type a command, press
34+
Enter, watch ocgv open." Instead each demo script *is* the scenario: it imports
35+
PSTui and invokes the cmdlet(s) directly, and `tuirec` drives the resulting
36+
TUI. (This is why the F7 demo records the history picker directly — see below.)
37+
38+
The demo scripts:
39+
40+
| Script | Records |
41+
|--------|---------|
42+
| `demo-ocgv.ps1` | `ls \| ocgv` then the `killp` process picker → `hero.gif` |
43+
| `demo-shot.ps1` | `Get-Process \| shot` tree exploration → `shot.gif` |
44+
| `demo-f7.ps1` | the `F7` command-history picker → `f7history.gif` |
45+
46+
## Composing keystrokes
47+
48+
Same token syntax as Terminal.Gui (`wait:<ms>`, `CursorDown`, `Enter`, `Esc`,
49+
`Tab`, backtick-quoted `` `literal text` ``). PSTui notes:
50+
51+
- **Type into the filter with `-Focus Filter`.** `ocgv` (and the F7 picker) take
52+
a `-Focus Filter` parameter so keystrokes land in the filter box and rows
53+
narrow *live* — the best thing to show. Then `Esc` (or `Enter` to select).
54+
- **`shot` has no `-Focus`; use `-FullScreen`.** The tree's inline render is
55+
finicky to position; `-FullScreen` gives a clean top-anchored capture. The
56+
first root is focused on open — `CursorRight` expands, `CursorDown` navigates.
57+
- **Quote the keystrokes in single quotes** (bash *and* PowerShell) so backtick
58+
literals survive: `ks='wait:1500,`src`,wait:2000,Escape'`.
59+
- **`killp` is safe in recordings** — `demo-ocgv.ps1` `Esc`s out of the picker,
60+
so no process is ever killed.
61+
62+
## Recipes
63+
64+
Run from the repo root. PSTui must be importable (`Install-Module PSTui`, or it
65+
auto-resolves from the built `./module`).
66+
67+
### `hero.gif` — `ls | ocgv` + `killp`
68+
69+
```bash
70+
export PATH="$(go env GOPATH)/bin:$PATH"
71+
ks='wait:1600,`src`,wait:2200,Escape,wait:2200,`Finder`,wait:2200,Escape,wait:1500'
72+
tuirec record --binary pwsh \
73+
--args "-NoLogo,-NoProfile,-File,./Scripts/tuirec/demo-ocgv.ps1" \
74+
--name hero --title "PSTui — ocgv" \
75+
--keystrokes "$ks" \
76+
--startup-delay 3200 --drain 1500 --cols 100 --rows 28 --keystroke-delay 140
77+
cp artifacts/hero.gif docs/PSTui/hero.gif
78+
```
79+
80+
### `shot.gif` — `Get-Process | shot`
81+
82+
```bash
83+
ks='wait:1800,CursorDown,CursorDown,CursorDown,CursorDown,CursorDown,wait:1500,CursorUp,CursorUp,CursorUp,CursorUp,CursorUp,wait:600,CursorRight,wait:1800,CursorDown,CursorDown,CursorDown,CursorDown,wait:1500,Escape,wait:1000'
84+
tuirec record --binary pwsh \
85+
--args "-NoLogo,-NoProfile,-File,./Scripts/tuirec/demo-shot.ps1" \
86+
--name shot --title "PSTui — Show-ObjectTree (shot)" \
87+
--keystrokes "$ks" \
88+
--startup-delay 3200 --drain 1200 --cols 100 --rows 28
89+
cp artifacts/shot.gif docs/PSTui/shot.gif
90+
```
91+
92+
### `f7history.gif` — the F7 command-history picker
93+
94+
```bash
95+
ks='wait:1700,`Get`,wait:2200,`-S`,wait:2000,Escape,wait:1200'
96+
tuirec record --binary pwsh \
97+
--args "-NoLogo,-NoProfile,-File,./Scripts/tuirec/demo-f7.ps1" \
98+
--name f7history --title "PSTui — F7 command history" \
99+
--keystrokes "$ks" \
100+
--startup-delay 3200 --drain 1500 --cols 100 --rows 22 --keystroke-delay 130
101+
cp artifacts/f7history.gif docs/PSTui/f7history.gif
102+
```
103+
104+
## Validate
105+
106+
`tuirec` writes to `artifacts/` (git-ignored); commit the copies under
107+
`docs/PSTui/`.
108+
109+
```bash
110+
# No errors leaked into the cast:
111+
grep -iE "error|not recognized|exception" artifacts/<name>.cast
112+
113+
# Not blank — eyeball a middle frame (needs python3 + Pillow):
114+
python3 -c "from PIL import Image; im=Image.open('artifacts/<name>.gif'); print(im.n_frames,'frames'); im.seek(im.n_frames//2); im.convert('RGB').save('/tmp/mid.png')"
115+
```
116+
117+
A good recording is **> ~20 KB** with several frames; a near-blank capture is a
118+
few KB / 2–3 frames (usually means keystrokes went to the wrong focus, or the
119+
target produced no output).
120+
121+
## Troubleshooting
122+
123+
| Problem | Cause | Fix |
124+
|---------|-------|-----|
125+
| "recording has no output events" / blank | Recording the bare pwsh REPL (it doesn't render in the PTY) | Record a demo `.ps1` that invokes the cmdlet directly |
126+
| Keystrokes seem ignored | Focus is on the tree/table, not the filter | `ocgv`: add `-Focus Filter`. `shot`: `Tab` to the tree, or it starts focused |
127+
| `shot` renders mid-screen / empty | Inline tree positioning | Use `-FullScreen` |
128+
| `--args` parsed into too many args | Commas in the PowerShell got split | Move the pipeline into a `-File` script (see above) |
129+
| Backtick literal text dropped | Shell ate the backticks | Single-quote the whole `ks='...'` |

‎Scripts/tuirec/demo-f7.ps1‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# F7 history demo for tuirec. The pwsh REPL itself does not render under a
2+
# recording PTY, so this reproduces exactly what pressing F7 shows: recent
3+
# command history in Out-ConsoleGridView (same shape Show-PSTuiHistory builds),
4+
# with the typed prefix used as the live filter.
5+
Import-Module PSTui -ErrorAction Stop
6+
7+
$history = @(
8+
'Get-Process | Out-ConsoleGridView'
9+
'Get-ChildItem -Recurse -Filter *.cs'
10+
'Get-Service | Where-Object Status -eq Running'
11+
'git log --oneline -20'
12+
'dotnet build PSTui.slnx -c Release'
13+
'Get-Content README.md | Select-String PSTui'
14+
'Install-Module PSTui'
15+
'Get-Date -Format o'
16+
'Get-History | Format-Table -AutoSize'
17+
) | ForEach-Object { [pscustomobject]@{ CommandLine = $_ } }
18+
19+
$history |
20+
Out-ConsoleGridView -OutputMode Single -Title 'Command History (F7)' -Focus Filter |
21+
Out-Null

‎Scripts/tuirec/demo-ocgv.ps1‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Hero demo for tuirec: `ls | ocgv` followed by the `killp` process picker.
2+
# Run head-less by tuirec (see README.md). We Esc out of both pickers, so no
3+
# process is actually killed.
4+
5+
Import-Module PSTui -ErrorAction Stop
6+
7+
# 1) ls | ocgv — browse the current directory as an interactive table.
8+
Get-ChildItem |
9+
Out-ConsoleGridView -Title 'ls | ocgv' -Focus Filter |
10+
Out-Null
11+
12+
# 2) killp — pick a process from a graphical chooser.
13+
Get-Process |
14+
Select-Object ProcessName, Id,
15+
@{ Name = 'CPU(s)'; Expression = { [math]::Round($_.CPU, 2) } },
16+
@{ Name = 'WS(MB)'; Expression = { [math]::Round($_.WorkingSet64 / 1MB, 2) } } |
17+
Out-ConsoleGridView -OutputMode Single -Title 'killp - pick a process' -Focus Filter |
18+
Out-Null

‎Scripts/tuirec/demo-shot.ps1‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SHOT demo for tuirec: explore objects as an interactive tree (full screen).
2+
Import-Module PSTui -ErrorAction Stop
3+
Get-Process |
4+
Sort-Object -Property CPU -Descending |
5+
Select-Object -First 15 |
6+
Show-ObjectTree -Title 'Get-Process | shot' -FullScreen

‎docs/PSTui/f7history.gif‎

22.3 KB
Loading

‎docs/PSTui/hero.gif‎

121 KB
Loading

‎docs/PSTui/ocgv.gif‎

-1.73 MB
Binary file not shown.

‎docs/PSTui/shot.gif‎

39.9 KB
Loading

0 commit comments

Comments
 (0)