Juri Pakaste
Juri Pakaste

Reputation: 1442

How can a TTY program work while stdout is piped to less?

I'm writing a text UI program that writes its output to and reads input from /dev/tty. It configures the alternative buffer, sets the terminal to raw mode, etc. It seems to work great, even when redirecting stdout to a file. But when I pipe stdout to less, less draws its UI over mine and things go haywire.

Some programs, such as fzf and fx, successfully draw their UIs while having the stdout piped to less. Many programs don't; vim, nvim and mg, for example, all fail. What's the correct approach here?

Upvotes: 0

Views: 26

Answers (0)

Related Questions