sharkdp/bat

feat: Compact headings mode

Opened this issue · 4 comments

Problem

Bat's headings take up quite a bit of vertical space, especially with larger fonts. --decorations never removes them, but also looses the line numbers and file name.

Solution

A flag that changes the rendering such that

  • The header spacers don't take two extra lines;
  • The lines don't draw a right margin.
$ bat program.scm
───────┬─────────────────────────────────────────────────────
       │ File: program.scm
───────┼─────────────────────────────────────────────────────
   1   │ ;; Example file
   2   │ (displayln "Hello, world!")
$ bat program.scm --decorations never
;; Example file
(displayln "Hello, world!")
$ bat program.scm --decorations compact
===> program.scm <===
1  │ ;; Example file
2  │ (displayln "Hello, world!")

Hey @walking-octopus 👋

I've added the compact mode feature as discussed. Image Everything is working smoothly now!

Let me know if you’d like any other changes before I raise the PR.

Thanks!

Hi. I didn't really expect anyone would immediately implement it. My only concern is that the implementation isn't bloated with special casing, but that's something for the code review.

I chose my example format based on how tail shows multiple concatenated files. It seems like it would also make it more greppable in the pager. If it stays in, that's fine, but if consistency or visuals come first, that's fine as well.

I hope there's still enough space for line numbers in this format.

Hi @walking-octopus 👋

Totally agree keeping the implementation clean and avoiding too many special cases is important. I aimed to make the compact mode logic minimal and self-contained, but happy to adjust based on review feedback.

Your example using the ===> file <=== format makes a lot of sense, especially from a greppability and multi-file context perspective. I’ll double-check the alignment and spacing to ensure the line numbers are still clearly visible and not cramped.

Let me know if you’d like to tweak the format further for consistency or aesthetics—happy to iterate!

Thanks again for the quick and thoughtful feedback 😊

Hi @walking-octopus 👋

Just a quick update: I have implemented the compact mode header as discussed. The new format now displays as:

Image

This keeps the logic minimal and self-contained, and should be both greppable and visually distinct, while leaving space for line numbers.
If you have any feedback on the format or want to tweak it further for consistency or aesthetics, just let me know—happy to iterate!

Thanks again for your thoughtful feedback and guidance!