From 51c8f9e6add7cc90c23816f1654d6aa58d936d21 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 30 Jun 2026 09:45:26 +0200 Subject: [PATCH] Always set LAZYGIT_COLUMNS The env var was previously set only on Windows, where the no-op pty stub was just running the command without a pty and needed to expose the width to pager scripts another way. With ConPTY coming to Windows the rationale disappears there, but the env var is documented in docs/Custom_Pagers.md for pager scripts that can't query the terminal width directly. Set it on every platform so those scripts remain portable, regardless of whether a pty is in play. Co-Authored-By: Claude Opus 4.7 (1M context) --- pkg/gui/pty.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/gui/pty.go b/pkg/gui/pty.go index f6356b9c0..fbe8d5d38 100644 --- a/pkg/gui/pty.go +++ b/pkg/gui/pty.go @@ -3,6 +3,7 @@ package gui import ( + "fmt" "io" "os" "os/exec" @@ -45,6 +46,12 @@ func (gui *Gui) onResize() error { // command. func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error { width := view.InnerWidth() + + // LAZYGIT_COLUMNS is documented in docs/Custom_Pagers.md for pager + // scripts that can't query the terminal width directly. We set it on + // every platform so those scripts remain portable. + cmd.Env = append(cmd.Env, fmt.Sprintf("LAZYGIT_COLUMNS=%d", width)) + pager := gui.stateAccessor.GetPagerConfig().GetPagerCommand(width) externalDiffCommand := gui.stateAccessor.GetPagerConfig().GetExternalDiffCommand() useExtDiffGitConfig := gui.stateAccessor.GetPagerConfig().GetUseExternalDiffGitConfig()