From 180fa9896118aff05ca990fd404404bd990c8dd0 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 11 Nov 2024 14:44:49 +0100 Subject: [PATCH] cli: set LESS=FRX when running $PAGER --- cli/src/ui.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/src/ui.rs b/cli/src/ui.rs index b57bf4d904..ddf9a3c84d 100644 --- a/cli/src/ui.rs +++ b/cli/src/ui.rs @@ -132,7 +132,11 @@ impl UiOutput { fn new_paged(pager_cmd: &CommandNameAndArgs) -> io::Result { let mut cmd = pager_cmd.to_command(); tracing::info!(?cmd, "spawning pager"); - let mut child = cmd.stdin(Stdio::piped()).spawn()?; + // LESS=FRX causes escape sequences to render correctly when PAGER=less + // It's harmless when using other pagers + let mut child = cmd + .env("LESS", "FRX") + .stdin(Stdio::piped()).spawn()?; let child_stdin = child.stdin.take().unwrap(); Ok(UiOutput::Paged { child, child_stdin }) }