In the default git pager (less on my system) I can use the mouse scroll wheel to scroll through the pager output. When delta is used, the mouse scroll does not work, and I'm forced to use the navigation shortcuts. It would be really nice to be able to scroll with the mouse wheel.
System: Linux pop-os 5.3.0-22-generic #24+system76~1573659475~19.10~26b2022-Ubuntu SMP Wed Nov 13 20:0 x86_64 x86_64 x86_64 GNU/Linux
Please. This is the one thing preventing me from using delta.
Hi, thanks for the report, let's get to the bottom of this. You might have to help me out a bit as I don't usually use a mouse. Are you familiar with bat? The code in delta relating to paging is literally copied from bat, and my intention in doing that was that the two projects would behave the same in these respects. So, there are many issues in the bat github repo concerning scrolling. Ultimately, the solution the bat author recommends is described here: https://github.com/sharkdp/bat#using-a-different-pager.
Would you be able to do the following?
Maybe you could help me understand something: I've read the various bat issues but I don't think I understand what people mean when they talk about "scrolling in less". I have just located a mouse and I find (in MacOS iTerm2 and Terminal.app) that the scroll wheel scrolls the terminal application's main scroll bar, and so "scrolling works" in a sense for delta, less and bat.
Tried to use bat, same problem as with delta.
Tried to set export BAT_PAGER="less -irRSx4", where the less options were copied from my $LESS env var, worked like a charm.
Try to run less -irRSx4 with a big file to see what we mean by scrolling, BTW.
worked like a charm.
OK, just to be totally clear, did it work like a charm in both delta and bat? (It should.) So maybe we can close this issue by updating the README to explain that the solution is the same as bat?
Did
export BAT_PAGER="less -irRSx4"work like a charm in both delta and bat? (It should.) So maybe we can close this issue by updating the README to explain that the solution is the same as bat?
@dandavison @Darkhogg thanks! I confirm that export BAT_PAGER="less -rR" fixes mouse wheel scrolling in both delta (e.g. showing a big diff) and raw bat (e.g. ls /usr/bin | bat). Notes:
i, S and x4 mentioned by @Darkhogg are unrelated.less' manpage suggests there is a nuance between r and R, but I couldn't be bothered to understand it. Both work fix mouse wheel scrolling, and bat's README suggests to use -Rexport BAT_PAGER="less -iRx4" it is.@dandavison a mention in the README seems appropriate to me too. Thanks for delta!!!
Oh, nice, I didn't realize that was supposed to make delta work, I just tried bat.
To confirm: It works in delta too, just checked.
The fact that I have to use a bat env var for this is a bit confusing but I'll take it.
@Darkhogg @ronjouch awesome, I'll add the explanation to the README.
@Darkhogg You actually don't have to use a bat env var; delta also honors the standard Unix PAGER env var (giving precedence to BAT_PAGER). And bat also honors both of them with the same precedence rule. My thinking was that adding a DELTA_PAGER to this would have been unnecessarily confusing :)
In general, my intention is for delta in some ways to be a companion tool to bat. bat does not implement language-specific syntax highlighting for diff output, or for the multi-language diff output produced by git diff (see https://github.com/sharkdp/bat/issues/23), since it's a different problem from the syntax-highlighting-a-single-language-file problem that bat solves. But both bat and delta are written in Rust and, since they both use syntect, they use the same format for color themes and language syntax descriptions. So, my intention is basically that a bat user's bat configuration will, where appropriate, be honored automatically by delta. So far, that is true for BAT_PAGER, and I plan (https://github.com/dandavison/delta/issues/19) to make delta read custom themes and syntax definitions from the same location as bat (~/.cache/bat), so that the same process can be used for adding new themes/languages: https://github.com/sharkdp/bat#adding-new-syntaxes--language-definitions. I'd be happy to hear any thoughts on whether this makes sense.
@Darkhogg You actually don't have to use a bat env var; delta also honors the standard Unix
PAGERenv var (giving precedence toBAT_PAGER). And bat also honors both of them with the same precedence rule.
Hmmm yes, and bat is supposed to user PAGER too, see bat's README / Using a different pager. However, setting PAGER to less -iRx4 didn't fix scrolling in bat, I did have to set BAT_PAGER to fix it. So, staying with BAT_PAGER. Not sure what's going on, maybe bat's handling of PAGER is confused by arguments?
@ronjouch is that the effect of the precedence rule? Is PAGER honored if you do unset BAT_PAGER first (assuming you're using bash).
As an extra level of complexity, I believe that for bat, setting the env vars to empty string (e.g. export BAT_PAGER=) will not cause them to be ignored: they have to be literally not set / unset. But for delta, I have made delta ignore the env vars if they are empty. I hadn't thought it through sufficiently to decide whether I should open an issue against bat or not.
@dandavison I'm using the fish shell, and I tested my change in a fresh session after editing my config.fish :
BAT_PAGER set to less -iRx4 (and PAGER unset), mouse scrolling works in ls -la /usr/binPAGER set to less -iRx4 (and BAT_PAGER unset), mouse scrolling doesn't work in ls -la /usr/binFor me, setting BAT_PAGER='less -R' works. PAGER isn't respected for me.
Ah sorry, that's right, bat (and therefore delta, which uses a bat's code here) replaces the arguments to less when PAGER is the only env var set. OK, it's all a bit confusing, and there's the --pager argument which bat has and delta does not currently. So plenty of degrees of freedom...
I'm glad we have a solution here and I'll ping this ticket again when I add an explanation to the README. (Unless someone else wants to which would also be great).
I think this issue can stay closed now. Thanks all and thanks @ronjouch who added a section on mouse scrolling to the README.
Hello people. First, what an incredible tool this is!
I know this is probably not a problem in delta, but if anyone can help me, I will be very grateful.
I'm using fish as my main shell, and my problem follows below:
If I set the EV using set -Ux BAT_PAGER "less -RF", then call zsh, the diff will be the way I want it.
So if inside the zsh I call the fish, the diff is also the way I want it.
However if I call the exit from fish to zsh and call the exit again to go back to the initial (or main) fish, the diff does not work the way I want.
I tried to set the environment variable through the ~/.config/fish/config.fish file but I also got the same behavior reported above.
I decided to ask here, because maybe if I had the --pager option, I could solve this problem as delta --pager="less -RF".
My less version was less 487 on MacOS mojave.
less --version
less 487 (POSIX regular expressions)
I just installed less from brew and linked it. Now scrolling just works. Didn't change any configs etc.
brew install less
brew link less
less --version
less 551 (PCRE regular expressions)
Copyright (C) 1984-2019 Mark Nudelman
Wonderful wonderful tool. I can't get scrolling to work on zsh. Tried less -iRx4 and less -R for BAT_PAGER. Happy to try anything else if you have thought :) Thanks all.
@freak4pc You could try to append --mouse or --MOUSE to the LESS (or BAT_PAGER) environment variable, depending on the direction you to use your mouse wheel in. :wink:
Your terminal emulator needs to support mouse events for this to work, of course.
The number of lines to scroll with the wheel can be adjusted with --wheel-lines=<n>.
Most helpful comment
@freak4pc You could try to append
--mouseor--MOUSEto theLESS(orBAT_PAGER) environment variable, depending on the direction you to use your mouse wheel in. :wink:Your terminal emulator needs to support mouse events for this to work, of course.
The number of lines to scroll with the wheel can be adjusted with
--wheel-lines=<n>.