Skip to content

Keep the input filename in pager prompts - #3984

Open
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:pager-filename-prompt-1855-20260907
Open

Keep the input filename in pager prompts#3984
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:pager-filename-prompt-1855-20260907

Conversation

@Matei02355

Copy link
Copy Markdown
Contributor

When bat sends highlighted input over a pipe, less cannot determine its original filename. Long files therefore lose their visible identity once the header scrolls away.

Pass a single input's display name to the pager. Standard less shows it in the short, medium, long and = prompts, while the built-in pager uses it as its footer. Named stdin and library input titles work too. Multiple inputs retain the normal prompt. If the user opens a different file inside less, its actual name is displayed.

Escape less prompt metacharacters and display control characters visibly. Pass prompt values as separate arguments so a dollar sign in a filename cannot introduce more less options. Explicit command-line prompts take precedence; potentially customized prompts in LESS are left alone. BusyBox and unknown pagers receive no filename options. The existing public OutputType::from_mode API remains available unchanged.

Fixes #1855.

Validation: 479 tests passed with all features and a single test thread, including six new process regressions; seven platform/manual tests were ignored. All-target/all-feature Clippy, formatting and the minimal regex-onig library build passed. Real PTY sessions with less 590 verified short/medium/long/= views and an explicit custom prompt; a real built-in pager session also displayed the sanitized filename and exited normally. These checks included spaces, punctuation, backslashes, dollar signs, newline, tab and ESC in the display name. An initial parallel run hit an unrelated LESSOPEN test; its focused rerun and the complete serial suite passed.

@Matei02355
Matei02355 marked this pull request as ready for review September 7, 2026 15:53
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.

How do I display the filename in the footer

1 participant