https://github.com/crramirez/casciian-ptypipe
https://github.com/crramirez/casciian-ptypipe
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/crramirez/casciian-ptypipe
- Owner: crramirez
- License: other
- Created: 2026-01-10T19:22:20.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-01-27T00:12:24.000Z (5 months ago)
- Last Synced: 2026-01-27T08:32:40.970Z (5 months ago)
- Language: C
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
ptypipe
=======
ptypipe is a small command-line utility that runs its first argument
in a pseudo terminal created with forkpty(). This is handy for the
following cases:
* Undoing glibc's behavior of buffering stdin/stdout, which makes
pipe-based wrapped command shells useless.
* Using a different window size for programs than the controlling
TTY.
* Notifying a pipe-based wrapped shell that the window size has
changed.
One can get a similar result to this program through other means. The
'script' utility supplied in most POSIX-like systems can emulate a
TTY. 'pipetty' (licensed GPL) is also available from the KBtin
source.
Usage
-----
```
ptypipe { command } { arguments }
```
Resizable Window Support
------------------------
ptypipe monitors its stdin for the dtterm/xterm sequence:
```
ESC [ 8 ; { rows } ; { cols } t
```
If this sequence is seen, it is stripped from the input to the child
process and ioctl(TIOCSWINSZ) is executed to notify the child of a new
window size. One could thus do something like:
```
/bin/echo -ne "\033[8;20;40t" | ptypipe ls
```
...and ls will execute with a window size of 20 rows by 40 columns.
[Jexer](https://gitlab.com/AutumnMeowMeow/jexer) illustrates how
ptypipe can work for a larger program. Jexer is 100% Java, but needs
to spawn interactive terminals. It can do this with either 'script'
or 'ptypipe'. Using 'script' results in terminal windows that cannot
be resized; using 'ptypipe' those terminal windows resize as expected
in modern programs.
Copyright Status
----------------
To the extent possible under law, the author(s) of ptypipe have
dedicated all copyright and related and neighboring rights to ptypipe
to the public domain worldwide. This software is distributed without
any warranty. The COPYING file describes this intent, and provides a
public license fallback for those jurisdictions that do not recognize
the public domain.
This code has been dedicated to the public domain, and are free for
relicense. People are free to replace the copyright headers with
whatever works for them -- no need to keep the current name on it.
This repository will stay frozen and public domain, in case people
need proof that this code really is free for everyone.
Bugs
----
If an ESC is in the stream ahead of a correct resize sequence, the
resize sequence is not noticed and will be emitted to the child
process.