Skip to content

Commit

Permalink
pager: PAGER support args
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Dec 25, 2024
1 parent 382df7c commit bcf4847
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/zeta/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/antgroup/hugescm/modules/env"
"github.com/antgroup/hugescm/modules/plumbing"
"github.com/antgroup/hugescm/modules/shlex"
"github.com/antgroup/hugescm/modules/zeta/object"
)

Expand Down Expand Up @@ -150,11 +151,16 @@ func NewPrinter(ctx context.Context) *Printer {
if len(pager) == 0 {
pager = "less"
}
pagerArgs := make([]string, 0, 4)
if cmdArgs, _ := shlex.Split(pager, true); len(cmdArgs) > 0 {
pager = cmdArgs[0]
pagerArgs = append(pagerArgs, cmdArgs[1:]...)
}
pagerExe, err := exec.LookPath(pager)
if err != nil {
return &Printer{useColor: isTrueColorTerminal, w: os.Stdout}
}
cmd := exec.CommandContext(ctx, pagerExe)
cmd := exec.CommandContext(ctx, pagerExe, pagerArgs...)

cmd.Env = env.SanitizerEnv("PAGER", "LESS", "LV") // AVOID PAGER ENV
// PAGER_ENV: LESS=FRX LV=-c
Expand Down

0 comments on commit bcf4847

Please sign in to comment.