c2c

PTY Injection

Core Finding

For this environment, the reliable path is writing to the PTY master, not the slave.

Correct Sequence

For message MSG:

  1. write \x1b[200~MSG\x1b[201~
  2. wait about 200 ms
  3. write \r

Why This Works

Claude Code’s terminal UI enables bracketed paste mode and handles pasted content as a unit.

Why /dev/pts/N Is Wrong

Writing to the slave PTY usually goes to display output rather than the input queue consumed by the terminal application.

Proven Helper

The helper used here is:

It already has the needed capability on this machine:

Environment Notes

This machine uses Ghostty and a single process can hold multiple PTY masters. The discovery code maps a target pts/N to the correct Ghostty master fd by scanning fdinfo for tty-index.