Skip to content

fix(pager): use temp file and TTY for interactive pagers like most - #984

Open
syf2211 wants to merge 1 commit into
charmbracelet:masterfrom
syf2211:fix/153-pager-tempfile-tty
Open

fix(pager): use temp file and TTY for interactive pagers like most#984
syf2211 wants to merge 1 commit into
charmbracelet:masterfrom
syf2211:fix/153-pager-tempfile-tty

Conversation

@syf2211

@syf2211 syf2211 commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Fixes glow -p failing when PAGER is set to interactive pagers like most that reject piped stdin.

Motivation

glow -p previously piped rendered markdown directly to the pager process stdin. Pagers such as most expect a file path argument and read keyboard input from the controlling terminal, so they exit with status 1 (#153).

Changes

  • Add runPagerCommand() that writes rendered output to a private temp file and passes the file path to the configured pager
  • Attach /dev/tty (or CONIN$ on Windows) for pager keyboard input
  • Include pager stderr in failure messages for easier diagnosis (complements include pager stderr in --pager failure messages #948)

Tests

  • go test ./... — all pass
  • Added pager unit tests covering temp-file handoff, pager flags, empty content, and stderr error propagation

Notes

  • Supersedes the diagnostic-only approach in include pager stderr in --pager failure messages #948 by fixing the underlying most compatibility issue while keeping improved error messages.
  • Large documents incur a brief temp-file write; this matches common pager integrations (man, git, etc.).

Fixes #153

Interactive pagers like `most` reject piped stdin but accept file
arguments. Write rendered markdown to a temp file, pass it to the pager,
and attach the controlling TTY for keyboard input.

Includes stderr in pager failure messages for easier diagnosis.

Fixes charmbracelet#153
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exit status 1 when used with most PAGER

2 participants