-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: a builtin pager for 'bat' #1053
Comments
Wow. I just came across bat the other day and fell in love with the beauty of it. Everything mentioned would make bat a leader in the paging category. Thanks for your passion and hard work |
The addition of vim color schemes would be great |
I'd also like to see this becoming a printer-friendly solution - not only the on-screen anchor, but per-printed-page anchors (header and footer). |
A lot of tools could be better with a good library for this. |
Is it an option to simply make the pager a separate program, and have bat recommend using it? That way Unix philosophy is followed more closely. |
@metov I'm not very picky and as long as it obeys my |
Found minus and wanted to share |
Thanks - sounds promising! |
One more thing, I found
|
It has a
|
As the list keeps growing - would you mind publishing your effort #1053 (comment), behind an experimental flag? Unless it raises the binary size too much for "just a wish" that is fully experimentally working. |
Sure - why not. I just "polished" it a little bit, but note that this is not much more than a quick & dirty proof of concept: https://github.com/sharkdp/riffle Instead of properly integrating this into What it can do:
What it can not do:
If someone on Linux/amd64 wants to try this out without compiling: bat-riffle.zip Screencast: https://asciinema.org/a/YhN35zGJxbnODvbDeXxTEDPG6 (note that I am resizing my terminal window in the last few seconds. Asciinema doesn't really show the full effect here. Before we go further with this, we should probably come up with a list of requirements and also a draft for the design of this new pager library. I'm not sure if the current callback-based implementation is the best way to proceed. We should also carefully check if one of the already available libraries (e.g. https://crates.io/crates/minus) would be suitable for our needs. |
I am not sure what did I do wrong $ bat-riffle ~/Documents/ISO_Next_Group-after-Shift.sh
bat-riffle: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by bat)
bat-riffle: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by bat)
$ uname -a
Linux h 5.13.0-28-generic #31~20.04.1-Ubuntu SMP Wed Jan 19 14:08:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ... but maybe: $ ldd --version
ldd (Ubuntu GLIBC 2.31-0ubuntu9.2) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper. That's from Ubuntu 20.04 |
This feature itself is not implemented to bat just yet but mentioned in this issue - sharkdp/bat#1053. Fortunately though I was able to use the proof-of-concept library by the creator of the bat, https://github.com/sharkdp/riffle and set it up to work for my need (press "e" to open editor) and this commit is the source code of how to make it work while waiting this feature to be ready on bat itself in the future.
This feature itself is not implemented to bat just yet but mentioned in this issue - sharkdp/bat#1053. Fortunately though I was able to use the proof-of-concept library by the creator of the bat, https://github.com/sharkdp/riffle and set it up to work for my need (press "e" to open editor) and this commit is the source code of how to make it work while waiting this feature to be ready on bat itself in the future.
While we're at it, the possibility to use two columns would be sweet ;-P e.g.:
😍 |
Fwiw, Honestly I wish they did more to generalize it, afaict it should work for any structured data/tree data, not necessarily |
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 ifless --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 withv
, like withless
#1607)--follow
support (Addfollow
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!
The text was updated successfully, but these errors were encountered: