profclems / glab

The GitLab CLI tool. Archived: now officially adopted by GitLab as the official CLI tool and maintained at https://gitlab.com/gitlab-org/cli. See https://github.com/profclems/glab/issues/983
https://glab.readthedocs.io/
MIT License
2.08k stars 163 forks source link

automatically run output in pager if it is longer than the height of the terminal #558

Open maxice8 opened 3 years ago

maxice8 commented 3 years ago

Describe the feature or problem you'd like to solve

When using a command with output that can become very long, it is super annoying that I have to scroll back up instead of having my system pager handle it for me.

Propose a Solution

Check if the final output is longer than HEIGHT of the terminal and start it in the user's pager.

Possibly have it as a config option that can be disabled since paging output is a very good user default.

virgilwashere commented 3 years ago

Or just use git core.pager and suggest a value using less -F

git config --get core.pager
diff-so-fancy | less --tabs=4 -RFX

From the less man page:

-F or --quit-if-one-screen
              Causes less to automatically exit if the entire file can be displayed on the first screen.

Update:

Just saw #320

setting GLAB_PAGER(or PAGER) didn't work.

GLAB_PAGER="less -RFX" glab ci list -P 100
clemsbot commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.