Skip to content

feat: Compact headings mode #3303

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

Open
walking-octopus opened this issue May 23, 2025 · 4 comments
Open

feat: Compact headings mode #3303

walking-octopus opened this issue May 23, 2025 · 4 comments
Labels
feature-request New feature or request

Comments

@walking-octopus
Copy link

walking-octopus commented May 23, 2025

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!")
@walking-octopus walking-octopus added the feature-request New feature or request label May 23, 2025
@narasimhauppala
Copy link

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!

@walking-octopus
Copy link
Author

walking-octopus commented May 26, 2025

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.

@narasimhauppala
Copy link

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 😊

@narasimhauppala
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants