Merge pull request #2020 from tgyurci/gh-pager-env
Add support for GH_PAGER
This commit is contained in:
commit
127d0b8717
2 changed files with 9 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue