diff --git a/pkg/cmd/root/help_topic.go b/pkg/cmd/root/help_topic.go index aacdfc5e5..bd23bc68a 100644 --- a/pkg/cmd/root/help_topic.go +++ b/pkg/cmd/root/help_topic.go @@ -28,7 +28,7 @@ func NewHelpTopic(topic string) *cobra.Command { DEBUG: set to any value to enable verbose output to standard error. Include values "api" or "oauth" to print detailed information about HTTP requests or authentication flow. - PAGER: a terminal paging program to send standard output to, e.g. "less". + GH_PAGER, PAGER (in order of precedence): a terminal paging program to send standard output to, e.g. "less". GLAMOUR_STYLE: the style to use for rendering Markdown. See https://github.com/charmbracelet/glamour#styles diff --git a/pkg/iostreams/iostreams.go b/pkg/iostreams/iostreams.go index 43fe8ca42..d13d7b542 100644 --- a/pkg/iostreams/iostreams.go +++ b/pkg/iostreams/iostreams.go @@ -248,6 +248,13 @@ func System() *IOStreams { stdoutIsTTY := isTerminal(os.Stdout) stderrIsTTY := isTerminal(os.Stderr) + var pagerCommand string + if ghPager, ghPagerExists := os.LookupEnv("GH_PAGER"); ghPagerExists { + pagerCommand = ghPager + } else { + pagerCommand = os.Getenv("PAGER") + } + io := &IOStreams{ In: os.Stdin, originalOut: os.Stdout, @@ -255,7 +262,7 @@ func System() *IOStreams { ErrOut: colorable.NewColorable(os.Stderr), colorEnabled: EnvColorForced() || (!EnvColorDisabled() && stdoutIsTTY), is256enabled: Is256ColorSupported(), - pagerCommand: os.Getenv("PAGER"), + pagerCommand: pagerCommand, } if stdoutIsTTY && stderrIsTTY {