Comments (27)
@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. π
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>
.
from delta.
Mac user here. I tried the steps outlined in the docs (install latest less
and/or BAT_PAGER='less -R'
) to no avail.
However, I did manage to get it working with BAT_PAGER='less -+X'
.
This is the same fix as suggested in this issue for diff-so-fancy
: so-fancy/diff-so-fancy#246.
from delta.
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
from delta.
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:
- Options
i
,S
andx4
mentioned by @Darkhogg are unrelated. less
' manpage suggests there is a nuance betweenr
andR
, but I couldn't be bothered to understand it. Both work fix mouse wheel scrolling, and bat's README suggests to use -R- Actually, bat's README suggests to use -RFX and maybe -S but, for me (Ubuntu 19.10), F causes null output, X breaks mouse scroll, and S doesn't fix it (π). So for me
export BAT_PAGER="less -iRx4"
it is.
@dandavison a mention in the README seems appropriate to me too. Thanks for delta!!!
from delta.
Another Mac user. Just updating less
with brew install less
worked for me.
from delta.
I think this issue can stay closed now. Thanks all and thanks @ronjouch who added a section on mouse scrolling to the README.
from delta.
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.
from delta.
It worked to me with:
export DELTA_PAGER="less --mouse"
On ~/.bashrc
from delta.
Please. This is the one thing preventing me from using delta.
from 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?
- Try out bat and see if you find the same problems with scrolling there as with delta.
- Tell me if the solution recommended by bat works for you in delta.
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.
from delta.
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.
from delta.
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?
from 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.
from delta.
@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 sharkdp/bat#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 (#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.
from delta.
@Darkhogg You actually don't have to use a bat env var; delta also honors the standard Unix
PAGER
env 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?
from delta.
@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.
from delta.
@dandavison I'm using the fish shell, and I tested my change in a fresh session after editing my config.fish :
- With
BAT_PAGER
set toless -iRx4
(andPAGER
unset), mouse scrolling works inls -la /usr/bin
- With
PAGER
set toless -iRx4
(andBAT_PAGER
unset), mouse scrolling doesn't work inls -la /usr/bin
from delta.
For me, setting BAT_PAGER='less -R'
works. PAGER
isn't respected for me.
from delta.
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).
from delta.
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"
.
from delta.
Hey there.
When I use e.g. DELTA_PAGER='less --mouse'
, then scrolling in delta
works for me, however it doesn't without, which is strange, as both my bat
and less
do support mouse scrolling out of the box.
188565 pts/8 S+ 0:00 git diff HEAD~10
188566 pts/8 Sl+ 0:00 /usr/bin/delta
188570 pts/8 S+ 0:00 less --RAW-CONTROL-CHARS --quit-if-one-screen
Apparently my delta uses less
per default and adds --RAW-CONTROL-CHARS --quit-if-one-screen
, but even with these options a standalone less
on some file has working mouse scrolling support.
There are no aliases or so, that would cause that.
Cheers,
Chris.
from delta.
Hi @calestyo, hm, definitely the same version of less
being used? Have you checked what ps
says for the other scenarios? Is it possible you have something in LESS
? There's some good discussion in this thread: #630
from delta.
Hey @dandavison
With my standalone less
and aliases cleared I got:
223440 pts/10 S+ 0:00 less
so no parameters, and:
$ cat /proc/223440/environ | tr '\0' '\n' | grep -Ei 'pager|less|delta'
LESSCLOSE=/usr/bin/lesspipe %s %s
LESSOPEN=| /usr/bin/lesspipe %s
_=/usr/bin/less
But these shouldn't affect scrolling (which works).
At the same time for delta
via git
:
225803 pts/13 S+ 0:00 git diff HEAD~10
225804 pts/13 Sl+ 0:00 /usr/bin/delta
225808 pts/13 S+ 0:00 less --RAW-CONTROL-CHARS --quit-if-one-screen
with:
$ cat /proc/225808/environ | tr '\0' '\n' | grep -Ei 'pager|less|delta'
LESS=FRX
LESSANSIENDCHARS=mK
LESSCHARSET=UTF-8
LESSCLOSE=/usr/bin/lesspipe %s %s
LESSHISTFILE=/home/calestyo/.local/share/delta/lesshst
LESSOPEN=| /usr/bin/lesspipe %s
(with scrolling not working)
Now delta
alone:
$ git format-patch HEAD~10 --stdout > foo.patch
$ cat foo.patch | delta
gives:
228058 pts/7 Sl+ 0:00 delta
228062 pts/7 S+ 0:00 less --RAW-CONTROL-CHARS --quit-if-one-screen
with:
$ cat /proc/228062/environ | tr '\0' '\n' | grep -Ei 'pager|less|delta'
LESSANSIENDCHARS=mK
LESSCHARSET=UTF-8
LESSCLOSE=/usr/bin/lesspipe %s %s
LESSHISTFILE=/home/calestyo/.local/share/delta/lesshst
LESSOPEN=| /usr/bin/lesspipe %s
_=/usr/bin/delta
(with scrolling working).
Now I played around and set LESS
manually to combinations of FRX
and ran cat foo.patch | delta
.
It's the X
in LESS
that breaks scrolling.
Next I wanted to see whether git
is the "offender" ;-) who sets the X
, and from my git_config
where I have these with respect to delta
:
[core]
pager = delta
β¦
[interactive]
diffFilter = delta --color-only
β¦
[delta]
navigate = true
I accidentally commented only:
[interactive]
diffFilter = delta --color-only
(which I merely have because of delta
βs README.md
)
But that's already it, with that, I get:
231643 pts/7 S+ 0:00 git diff HEAD~10
231644 pts/7 Sl+ 0:00 /usr/bin/delta
231648 pts/7 S+ 0:00 less --RAW-CONTROL-CHARS --quit-if-one-screen
and:
$ cat /proc/231648/environ | tr '\0' '\n' | grep -Ei 'pager|less|delta'
LESS=FR
LESSANSIENDCHARS=mK
LESSCHARSET=UTF-8
LESSCLOSE=/usr/bin/lesspipe %s %s
LESSHISTFILE=/home/calestyo/.local/share/delta/lesshst
LESSOPEN=| /usr/bin/lesspipe %s
So I'd guess it's in fact delta
, which adds the X
when --color-only
is used?!
Is it really needed (I guess so)?
And if, couldnβt you just also add --mouse
?
That would make behave more like people expect from less
.
At least my less
scrolls per default, even without --mouse
). I looked into that, and it seems to be a VTE speciality (presumably it sends UP and DOWN?).
Trying it in xterm
and my less
no longer scrolls per default (unless --mouse
is given).
So probably, you should actually not not add --mouse
, unless perhaps you detected that VTE is used (e.g. via the VTE_VERSION
env var).
But problem with that would still be, that there'd be no longer a direct way for people do specifically disable mouse scrolling (there is no --no-mouse
option, so you'd need to add some option to delta
to disable that quirk).
Yeah not really sure what would be the best way to go.
Cheers,
Chris.
from delta.
Hm, neither delta, nor the bat crate that delta uses in places, alter the LESS
env var, AFAIK. (But we do add arguments to the child process invocation when the user has not configured less
themselves)
Also my understanding is that the [interactive]
stanza in gitconfig is only in effect during operations such as git add -p
or --interactive
.
Could you double check the part of your experiment where you found that
[interactive]
diffFilter = delta --color-only
adds X
to the LESS
env var under a git diff
invocation? I don't think that should be the case.
from delta.
Uhm... I have no idea how I've managed to mess that up ^^ (=sorry)
Trying it again, I couldn't reproduce it.
So dug further and found:
https://github.com/git/git/blob/aab89be2eb6ca51eefeb8c8066f673f447058856/Documentation/config/core.txt#L550-L562
So git is the "offender" ;-) ... an in fact, even the delta
process has the env var already set to FRX
.
I've asked at the git mailing list, why they even add X
, presumably to avoid clearing the screen after exiting.
Next I'd ask less upstream, why X
causes VTEβs scrolling to break, and whether there's some out-of-the-box solution.
from delta.
Ok great, that's progress!
from delta.
Hm is there any cross-platform solution that would work on Windows? (like native Rust tools do) less
is not really an option here unless I install from GNU utils or something.
from delta.
Related Issues (20)
- Navigate keybinds only go between hunks, not files
- update intsructions for tmux color issues
- π Online user manual website not working HOT 4
- π When piping --help, the output should not contain escape chars
- π `--color-only` doesn't produce any colour HOT 2
- π diff chinese words better HOT 2
- π Highlighting of capitalisation changes does not match `diff-so-fancy` when using `delta diff-so-fancy` HOT 1
- π Emacs lisp incorrect highlighting HOT 1
- π hjkl key bindings as arrow keys HOT 2
- π Enable using delta in git when output is piped (`git diff | cat`) HOT 3
- π use diff-compatible exit statuses that differ between difference-found and error HOT 8
- π Please add support for cargo-binstall HOT 1
- π wrong highlight with `rg --json | delta` when tabs are involved HOT 2
- π `ws-error-highlight`
- π Homebrew cannot install from HEAD HOT 2
- π delta fails to run (in some cases) when `git` is not installed
- π White space before 2nd, 3rd `k` shouldn't be in highlighted scope
- π delta not respecting LESS -F environment variable (--quit-if-one-screen) HOT 2
- π Syntax highlighting fails when the visible snippet includes a multiline comment HOT 2
- π error: unexpected argument '--generate-completion' found
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from delta.