sharkdp/bat

Line number display change _while_ viewing a file

Closed this issue ยท 4 comments

This basically goes back to this comment from @why-not-try-calmer.

Usually, when viewing a file, I don't know in advance whether I want to copy sth out of it or not. Yet, I do prefer to have line numbers.

With a bat/less combo, this seems ... impossible? The screenshot below illustrates the issue:

  • On my system, bat is enabled with "default line numbers", a view I really like.
  • Now, I cannot copy properly, because of the line numbers.
  • If I want to disable line numbers, my "muscle memory" presses "-n". Result: less tells me that it is already not using line numbers.
  • Somewhat confused, I enable line numbers in less, and see the result of the screenshot.

I would really appreciate a way to have the same functionality as with less only (-n / -N), yet I am also blank about how to achieve this with two programs that basically don't communicate.

Image

What if you will try to alias bat to something like

alias bat -n="bat -p"

This works for me at least

What if you will try to alias bat to something like

alias bat -n="bat -p"

This works for me at least

Sure, but in that case the numbering does not "work" properly any more โ€“ it's basically off by three all the time, see the picture in my original description.

with less you can enable and disable the numbering, with bat ... not any more, unless you're willing to accept "off-by-three" numbers.

please correct me if I'm wrong :/

Basically you'd need to wait for bat to implement an interactive pager instead of passing the output to the pager after bat has finished processing it - i.e. a pager as a library instead of a separate process.
See #1053 and #1540

@keith-hall oh great :) . but since those tickets are rather old i'd say this is not going to happen soon, probably? ๐Ÿ˜ฌ (i can't do rust at all, so I'm not a big help here).

anyway, closing this โ€“ and watching your mentioned tickets. thanks for the answer!