Open sharkdp opened 4 years ago
Links added; feel free to use my text and remove the comment
Let's use this ticket to discuss some ideas and possible upsides/downsides of writing our own custom pager library that we could use instead of calling an external $PAGER
process (or, essentially, less
).
A few advantages if we would use a builtin pager in bat
:
less
. Consistent "quit if one screen" handling, and much more (Default pager breaks colours in Windows Terminal #860, Garbage unicode chars on wide screen display #1000, Can't open Dockerfile or .dockerfile #717, Bat does not work as file viewer for Midnight Commander for small files #710, pager="less -RF" breaks on macOS for single-page, but default pager breaks pgup/pgdn #681, File content not printed #520, Bat quickly exits #415, Bat with BAT_PAGER set doesn't work on small files #312, Always displays escape characters #271, Horizontal line wraps if less --status-column
is used as pager #519, Width is wrong when using less as pager with -J option #376, Since recent update, short files that do not require paging are displayed and then lost #887, Bat opens a file and close it itself in a second on Windows #943, Can't view some files #838, …)v
command does not work with a file as arg #528, Cannot edit standard input (Press RETURN) #697, Have the ability to open a vim session from bat (like less) #1051, Open file with v
, like with less
#1607)--follow
support (Add follow
option #457, Pass in "Ctrl-C" to pager? #808)--tabs
should be 0 by default instead of 4 #980, --tabs 0 is realy 8 #894)General advantages of a "pager" as a library (not just for bat
):
The obvious downsides are:
less
comes with 36 years(!!) of experience.One way to circumvent the second point would be to make this an opt-in feature, at least in the beginning.
I have actually started to implement a really simple cross-platform pager-as-a-library like this in a private repository. The first results look promising 😄
I'd be happy to hear about your thoughts and ideas!
Advantages of a "pager" as a library:
A few advantages if we would use a builtin pager in
bat
:less
. Consistent "quit if one screen" handling (#860, #1000, #717, #710, #681, #520, #415, #312, #271, #519, #376, #887, #943, #838, …)--follow
support (#457, #808)