From 886a5b3d240e0c94ff239d887fb55f7b0cbb770b Mon Sep 17 00:00:00 2001 From: sharkdp Date: Wed, 26 Sep 2018 18:03:46 +0200 Subject: [PATCH] Document the situation with less and scrolling closes #312 closes #246 --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 16dded0b..7d54b3e0 100644 --- a/README.md +++ b/README.md @@ -263,9 +263,22 @@ script as a wrapper, for example: ```bash #!/bin/bash -less --tabs 4 -RF "$@" +less --tabs 4 -R "$@" ``` +**Note**: By default, if the pager is set to `less`, `bat` will pass the following command line +options to the pager: `-R`/`--RAW-CONTROL-CHARS`, `-F`/`--quit-if-one-screen` and `-X`/`--no-init`. +The first (`-R`) is needed to interpret ANSI colors correctly. The second option (`-F`) instructs +less to exit immediately if the output size is smaller than the vertical size of the terminal. +This is convenient for small files because you do not have to press `q` to quit the pager. The +third option (`-X`) is needed to fix a bug with the `--quit-if-one-screen` feature in old versions +of `less`. Unfortunately, it also breaks mouse-wheel support in `less`. If you want to enable +mouse-wheel scrolling, you can either pass just `-R` (as in the example above, this will disable +the quit-if-one-screen feature), or you can use a recent version of `less` and pass `-RF` which +will hopefully enable both quit-if-one-screen and mouse-wheel scrolling. + +If scrolling still doesn't work for you, you can try to pass the `-S` option in addition. + ## Using `bat` on Windows `bat` mostly works out-of-the-box on Windows, but a few features may need extra configuration.