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

+14
View File
@@ -1586,6 +1586,20 @@ fn pager_more() {
});
}
/// The status column of less (-J, e.g. from $LESS) makes lines wrap onto
/// the decorations, so it has to be reset when bat builds the less arguments
#[test]
#[cfg(unix)]
fn pager_less_resets_status_column() {
bat()
.arg("--pager=../mocked-pagers/less.sh")
.arg("--paging=always")
.arg("test.txt")
.assert()
.success()
.stdout(predicate::str::contains("-+J"));
}
#[test]
fn alias_pager_disable() {
bat()
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
echo "$@"