-
-
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
Width is wrong when using less as pager with -J option #376
Comments
That is unfortunate, but I think it will be really difficult to handle this in Several ideas/workarounds come to my mind:
|
I figured it wouldn't be an easy problem to fix but wanted to bring it up if others encounter it. And if there maybe was a workaround, which you presented a few. Thanks for that! What about adding a "--terminal-width-offset" option? That way the offset could be adapted to what version of less is currently in use. Maybe it's not worth the clutter in the code since there are acceptable workarounds. |
I thought about that, too. We could maybe just support something like |
Allows the `width` argument to `--terminal-width` to be an offset instead of an absolute number. Examples: --terminal-width=80 # Set output width to 80 characters --terminal-width=-2 # Set output width to actual_width - 2 closes #376
Allows the `width` argument to `--terminal-width` to be an offset instead of an absolute number. Examples: --terminal-width=80 # Set output width to 80 characters --terminal-width=-2 # Set output width to actual_width - 2 closes #376
Oh, forgot to leave a reply. The ability to set an offset is awesome! Thanks for a great tool and all the feedback! |
This is now available in bat 0.9. |
this is a simple issue but can be a bit tricky to track, took me forever to understand what was wrong here: I solved it by adding |
@melissaboiko I don't quite understand. #392 proposes another solution to this problem. And I don't know what |
Funny less(1) syntax but The Of course, the offset option works too, and has the advantage of keeping up the less(1) status column if the person wants that inside bat. Currently when you generate a sample config file there are these lines: # Uncomment the following line if you are using less version >= 551 and want to
# enable mouse scrolling support in `bat` when running inside tmux. This might
# disable text selection, unless you press shift.
#--pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse"
I think similar comments could be helpful here, like # Uncomment the following line if you use the less(1) -J/--status-column option
# (either on --pager or via $LESS), to allow space for the status column:
# --terminal-width=-2
#
# (Or disable the less(1) status column in bat by adding --+status-column to --pager).
It's a bit dirty coupling but conceivably we could even peek into --pager/$PAGER/$LESS and if less -J / less --status-column is detected, do terminal width -2 by default… I mean if you're into that kind of thing. |
That sounds great!
I kind of like this 😄. But maybe it's a bit too much magic and would come with new problems. |
I also just struggled with this issue. Took quite a while to debug. When Once I finally figured out the problem and found this issue it was pretty easy to fix it in my bat config thanks to the handy |
The output from bat is one column to wide when less adds a status column to the left edge.
Setup
touch file
export BAT_PAGER
Compare
BAT_PAGER="less -R"
bat file
To
BAT_PAGER="less -JR"
bat file
The text was updated successfully, but these errors were encountered: