ptyrec starts a program in a pseudo-terminal and:
- relays stdin to the program
- relays program output to stdout
- records PTY output in a binary log file
- injects scripted input from command files
- optionally generates SRT subtitles synchronized with scripted input
Because Git does not preserve file timestamps, using the supplied
build.sh script is recommended.
ptyrec [-V]
[-l log]
[-w width]
[-h height]
[-i commands]
[-s subtitles]
[-d duration_ms]
[-o offset_ms]
[--]
program [args...]
-l logLog file path.
Default:
ptyrec.log.-i commands- Initial command file.
-s subtitlesSubtitle file path.
Default:
ptyrec.srt.-d duration_msSubtitle duration.
Default: 300 ms.
-o offset_msSubtitle time offset.
Examples:
-o 500 -o F500 -o B250
-w width- Initial terminal width.
-h height- Initial terminal height.
Command files may contain UTF-8 text and the following directives.
\s[n]Set inter-keystroke delay to n ms.
Values below 50 ms are clamped to 50 ms.
\S[n]- Pause once for n ms.
\u[hh ...]- Inject up to four bytes written as hexadecimal pairs.
\xhh
\x[hh ...]- Inject arbitrary bytes written in hexadecimal.
\Cc- Inject a control character.
\Mc- Inject an ESC-prefixed character (Meta/Alt modifier).
\R[file]- Include another command file.
\W[widthxheight]- Resize the pseudo-terminal.
\c[...]- Send a color sequence to the child program.
\d[...]- Display a color sequence locally without sending it to the child.
\D[...]- Change subtitle styling only.
Examples:
\c[31] \c[31;1] \c[red] \c[yellow,bold] \c[#00ff00] \c[]
\k- Enable or disable subtitle generation.
Subtitle cues are emitted only after the corresponding scripted unit has been completely delivered to the pseudo-terminal.
Subtitle styles support:
- colors
- bold
- italic
- underline
- strike-through
\m[file]- Load a subtitle map.
A subtitle map associates byte sequences with replacement text.
Example:
h ← j ↓ k ↑ l → \u0b Ctrl Home \u0a Ctrl End
If a key is present without replacement text, subtitle output for that exact sequence is suppressed.
The log contains bytes read from the child pseudo-terminal.
Display-only sequences generated by \d are never written to the log.