Skip to content
p-genPublic

About

A rewrite of ptylie. Starts a program in a pseudo-terminal (PTY), relays standard input, interprets a command file, displays PTY output, and records PTY output in a binary log.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

ptyrec.gif

Description

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

Building

Because Git does not preserve file timestamps, using the supplied build.sh script is recommended.

Synopsis

ptyrec [-V]
       [-l log]
       [-w width]
       [-h height]
       [-i commands]
       [-s subtitles]
       [-d duration_ms]
       [-o offset_ms]
       [--]
       program [args...]

Options

-l log

Log file path.

Default: ptyrec.log.

-i commands
Initial command file.
-s subtitles

Subtitle file path.

Default: ptyrec.srt.

-d duration_ms

Subtitle duration.

Default: 300 ms.

-o offset_ms

Subtitle time offset.

Examples:

-o 500
-o F500
-o B250
-w width
Initial terminal width.
-h height
Initial terminal height.

Command Files

Command files may contain UTF-8 text and the following directives.

Timing

\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.

Input

\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.

Terminal

\W[widthxheight]
Resize the pseudo-terminal.

Colors

\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[]

Subtitles

\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

Subtitle Maps

\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.

Logging

The log contains bytes read from the child pseudo-terminal.

Display-only sequences generated by \d are never written to the log.

About

A rewrite of ptylie. Starts a program in a pseudo-terminal (PTY), relays standard input, interprets a command file, displays PTY output, and records PTY output in a binary log.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages