> Traditional pagers like more or less weren't made for integrating into other applications. They were meant to be standalone binaries that are executed directly by users. However most applications don't adhere to this and exploit these pagers' functionality by calling them as external programs and passing the data through the standard input.
Do people widely agree with this? That sounds less like 'exploitation' to me and more like 'the way Unix works'.
> This method worked for Unix and other Unix-like OSs like Linux and MacOS because they already came with any of these pagers installed. But it wasn't this easy on Windows; it required shipping the pager binary along with the applications. Since these programs were originally designed for Unix and Unix-like OSs, distributing these binaries meant shipping an entire environment like MinGW or Cygwin so that these can run properly on Windows.
So, to support Windows, we have to:
- Abandon (maybe bypass) the core Unix principle of composing programs to carry out more complex tasks - Reimplement a pager library in every language
Is that really the best approach? Even if so, I would have thought a minimal pager would be best, but the feature list of this pager library is fairly extensive: https://github.com/AMythicDev/minus?tab=readme-ov-file#featu...
Do One Thing*†‡ And Do It Well⹋
* Parsing text formats counts as zero things
† UX counts as two things
‡ APIs that do multiple operations that people might want to split, with no individual APIs for the parts, count as doing one thing
⹋ Something that relies on cooperation from every other process on the system but has no way to enforce it counts as done well
Nobody bothers with this argument when the library is for, like, HTTP clients, or PKZIP containers. Unix philosophy, like most philosophy, exists mostly to be debated, and to be related to the history of the world, rather than to be actually implemented in the modern day.Pagers are practically the worst thing to make this argument about, because they mesh perfectly with the strings-only nature of Unix. They take a string and allow the user to navigate through it. They only need to be fast at human-recognizable speeds, there's little reason for them to be highly concurrent, and there's a lot of value in allowing the user to choose which pager they want they to use.
More broadly, there's also value in composable tools because users can use the one they're familiar with. I can learn how jq works and use it with anything that outputs JSON, rather than having to learn the syntax of 18 different libraries various app developers have chosen for querying JSON. I can pipe whatever I want into 'more' instead of having to learn the keybinds for each of the 5 popular paging libraries.
It's not perfect, but I do think it's better than the embedded alternative for a lot of things.
I personally don't. UNIX is made to be composable, and it's composition. more, less, most all consider pipe input as first-class citizens. I'm personally fond of "grep --color=always file.ext | less --raw" to page colored output.
> Is that really the best approach?
I don't think so. If I was the developer, I'd embed the pager only into the Windows build by default, and use system pagers on other systems (by default). If any person/distro wants to use the built-in pager, it'd be their choice.
I don't like when developers bloat their own code with good intentions, but drift from their nice state to something bloated.
I feel that for a tool like bat, it is better to have it built-in and not follow the composable philosophy because it is just so much more convenient. Of course the minus integration in bat is fairly basic at the moment, I guess supporting different code paths for static pagers vs interactive would increase maintenance burden quite a lot...
It can't adjust the columns in a table, but then I don't believe that `bat` can either, and I'm not aware of any similar program that can. (If there is one, please let me know.)
In the case of `bat` (or `man` or other programs that use a pager) it often requires no extra typing either, since `bat` will pipe it's output to `less` by default (or whatever you specify with the `PAGER` environment variable).
The `less` command can be quite a bit more powerful than it initially looks. I'd recommend looking over the man page sometime -- you might be surprised. In fact, looking over the `minus` page, other than being able to be compiled into another program so it doesn't have to be shipped separately on Windows, I'm not sure what it can do that `less` cannot. (If I'm missing some killer feature, please let me know. I'm not trying to bash `minus`, I just don't know what more it offers.)
Unlike cat, bat already seems deeply interested in the presentation of text on a terminal. Pagination involves several aspects of presentation of text on terminals. So, it's still arguably one thing from a conceptual perspective.
Not knowing much about bat (so I don't know how much this has already been thought of), I could even see bat and pager integrating in a way that you couldn't easily as separate programs. Supporting a feature where the opening lines of a paragraph, or a new section, are deferred to the next page, for example.
But this is not really practical for many use cases which are not filters first and foremost. So we end up with still reading from STDIN or the list of files presented as arguments. We write to the file given by -o (or --output) which can be "-" to signify STDOUT.
I find this pattern very flexible because it allows multiple input files or STDIN and a single output file which can be STOUT, so you still get your filtering behaviour if you want.
(For completeness sake, there is a third pattern somewhat prevalent. In call these copy type programs. They treat the last argument specially, usually as some form of target, like `cp a b c target`.)
I wonder how long ago it was I last used it - must’ve been sometime around 2010 or a few years earlier..
Exclamation marks seemed to be popular in names back in the day :D
So while I admire the engineering effort, I still find utility of these tools limited.
[1]: Assuming you use the `--paging=never` flag in your alias as the README suggests.
I have these aliases, which are useful when piping output to them:
alias bd='bat -p -l diff'
alias bh='bat -p -l help'
alias bi='bat -p -l ini'
alias bj='bat -p -l json'
alias bl='bat -p -l log'
alias bm='bat -p -l man'
alias by='bat -p -l yml' alias bat='rview'
rview from vim, OFC.Problem solved, you don't overwrite the files, you get all the vim options and a much better syntax highlighting.
Oh, and, as a plus, you gain xxd, which can be useful in tons of contexts.
Just tried it out yesterday and it by default output white text on my white background terminal. :(
fd, a better find: https://github.com/sharkdp/fd
ripgrep (rg) a modern grep: https://github.com/BurntSushi/ripgrep
eza for ls replacement: https://github.com/eza-community/eza
duf is a cleaner df: https://github.com/muesli/duf
dust for du: https://github.com/bootandy/dust
Also fish + starship + yazi + helix, all of which mostly work perfectly with the defaults
https://github.com/sharkdp?tab=repositories&q=&type=source&l...
it's useless without such a small thing.
edit: [n] G Go to the very bottom of the output. If n is present, goes to that line
Oh capital G. What an intuitive keyword source:https://docs.rs/minus/latest/minus/#standard-actions
The classic file viewer for a terminal is cat (or less).
Bat is a file viewer in every sense. I have concatenated multiple files using bat. It does come in handy sometimes. But even the concatenated output is designed to be a visual aid, not the traditional concatenation that cat does.
Example: If you're navigating to the folder of a git repository in your terminal and quickly want to see what the readme says without having to open a file manager or going to the website on github/gitlab/codeberg you can run:
cat README.md
Which shows the text stored in that file directly in your terminal window.bat does essentially the same, only fancier, with syntax highlighting, some formatting and colors.
Concatenate FILE(s) to standard output.
With no FILE, or when FILE is -, read standard input
https://man7.org/linux/man-pages/man1/cat.1.htmlhttps://en.wikipedia.org/wiki/Batch_file
https://www.ritlabs.com/en/products/thebat/
Expanded...
I have 2 mental definitions of "bat" as a term in computing. Only one can be interpreted as a standalone piece of software that has a version number. And this isn't it.