Pass -+J to less to turn off the status column

With -J in $LESS, less draws a status column two characters wide on
the left, so lines that bat already wrapped to the terminal width wrap
a second time and the rest of them ends up over the line numbers.

Reset the option with -+J next to the other default less arguments and
skip it for BusyBox less like -K, since it does not support it either.
+J does not work here, less runs it as the J command on startup.

Closes #2497
This commit is contained in:
dualfroz committed 2026-10-18 13:22:24 +02:00
1 parent fcaf1acdc8
commit daa163bc7d
5 files changed
+28 -1

No files matched your search

+4 -1
View File
@@ -666,7 +666,7 @@ Instead of using environment variables, you can also use `bat`'s [configuration
When using `less` as a pager, `bat` will automatically pass extra options along to `less`
to improve the experience. Specifically, `-R`/`--RAW-CONTROL-CHARS`, `-F`/`--quit-if-one-screen`,
`-K`/`--quit-on-intr` and under certain conditions, `-X`/`--no-init` and/or `-S`/`--chop-long-lines`.
`-K`/`--quit-on-intr`, `-+J` and under certain conditions, `-X`/`--no-init` and/or `-S`/`--chop-long-lines`.
>[!IMPORTANT]
> These options will not be added if:
@@ -687,6 +687,9 @@ have to press `q` to quit the pager.
The `-K`/`--quit-on-intr` option instructs `less` to exit immediately when an interrupt signal is received.
This is useful to ensure that `less` quits together with `bat` on SIGINT.
The `-+J` option turns off the `-J`/`--status-column` option, e.g. when it is set in the `LESS` environment variable.
The status column takes up two columns, so lines that `bat` already wrapped to the terminal width would wrap again.
The `-X`/`--no-init` option is added to versions of `less` older than version 530 (older than 558 on Windows) to
fix a bug with the `-F`/`--quit-if-one-screen` feature. Unfortunately, it also breaks mouse-wheel support in `less`.
If you want to enable mouse-wheel scrolling on older versions of `less` and do not mind losing