Repository navigation
Pager should not be used for empty output #6400
Description
Activity
could perhaps be solved on the user side with an additional flag in the less command, e.g.
-F/--quit-if-one-screen.❯ less --version | head -1 less 608 (PCRE2 regular expressions) ❯ man less | grep -A 3 'quit-if-one-screen' -F or --quit-if-one-screen Causes less to automatically exit if the entire file can be dis- played on the first screen.
mgabeler-lee-6rs commented
on Oct 7, 2022 ContributorAuthorMore actionsAah, yeah, and
ghtries to set that for common cases via theLESSenvironment variable:
cli/pkg/iostreams/iostreams.go
Lines 198 to 200 in 0ecd424
if _, ok := os.LookupEnv("LESS"); !ok { pagerEnv = append(pagerEnv, "LESS=FRX") }
but I have a more .. complex$LESSalready set without-F(so that if I explicitly dofoo | less, I'm sure to getlessinvoked)The gh config or
GH_PAGER="less -F"works as a workaround 👍Reacted by LangLangBartJust for clarification for any maintainer.
I also set the environment variable
LESSwithout the flag-F, therefore I getByte 0/0 (END)as seen in the GIF.# .zshrc # <--------- Less---------- > # from https://github.com/nablaa/dotfiles/blob/master/.zsh/environment.zsh # R - Raw color codes in output (don't remove color codes) # K - quit less immediately with ^C # q - be more quiet # M - Long prompts ("Line X of Y") # ~ - Don't show those weird ~ symbols on lines after EOF # g - Highlight results when searching with slash key (/) # I - Case insensitive search # s - Squeeze empty lines to one # w - Highlight first line after PgDn export LESS="-RKqM~gIsw" # Less Colors for Man Pages export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold export LESS_TERMCAP_me=$'\E[0m' # end mode export LESS_TERMCAP_se=$'\E[0m' # end standout-mode export LESS_TERMCAP_so=$'\E[01;31m' # begin standout-mode - info box export LESS_TERMCAP_ue=$'\E[0m' # end underline export LESS_TERMCAP_us=$'\E[01;32m' # begin underline # disable the creation of the ~/.lesshst file export LESSHISTFILE=-
I guess the issue can be closed ?
Thanks for the discussion so far!
Every tool I use that understands this variable, except
gh, understands that output smaller than a single terminal window doesn't need to go through the pager.Here is git CLI piping output definitely smaller than my terminal window through the configured pager:
It is not the responsibility of the tool itself to determine your viewport size and how to handle pagination. Instead, that is the responsibility of the pager utility itself. Thus, gh will always start a pager for any amount of output. But, you are right that starting a pager for no output whatsoever is not really great user experience. Let's fix that!
In the meantime please use the already discovered workaround by setting the
LESS=FRXenvironment variable orGH_PAGER=less -FRX.- addedpriority-3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetichelp wantedContributions welcomeContributions welcomeand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Oct 10, 2022 - changed the title
[-]Pager should be used only when output doesn't fit on screen[/-][+]Pager should not be used for empty output[/+]on Oct 10, 2022


Describe the bug
I have
PAGERset in my environment to tell various tools my preferred pager. Every tool I use that understands this variable, exceptgh, understands that output smaller than a single terminal window doesn't need to go through the pager. Withgh, it seems the only options are to run everything through a pager, or nothing. Including empty output!This is annoying and frustrating.
Steps to reproduce the behavior
export PAGER=lessgh pr listlessbeing opened to displaybyte 0/0 (END)ghdid produce some output ... that it didn't send to the pager, but which is hidden due to the presence of the pager, until you quit it:no open pull requests in owner/reponameexport GH_PAGER=to make this stopExpected vs actual behavior
I expect
ghto use the configure pager only when there is enough output to merit pagination, like every other tool that supports such config. Compare especiallygitLogs
N/A