dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.36k stars 360 forks source link

🐛 delta not respecting LESS -F environment variable (--quit-if-one-screen) #1605

Closed eggbean closed 5 months ago

eggbean commented 5 months ago

I have set LESS=-MRQx4FX#10 in my environment and have had it like this for years.

When I started using delta a few years ago I disabled it working on git branch and git stash, as the -F in the $LESS variable was not being respected so I always had to exit the short screens for those commands. I left it like this for years and forgot about it.

[pager]
    stash = false
    branch = false

Recently I decided that I would like to have delta format git stash -p, so I re-enabled delta for stashing (and branch) and have encountered this problem again with git stash and git branch.

Why won't delta/less print and exit on short screens like git stash and git branch? I will have to disable delta working on these commands yet again, as it's too annoying.

I'd really like to finally sort this problem out though.

(this is on Linux. I have different experience on Windows where it works as I would like it to, but I had to disable -X for some reason)

eggbean commented 5 months ago

I figured it out. I need to override my $LESS with DELTA_PAGER='less -F', or whatever is happening, it seems to work. `

eggbean commented 5 months ago

Of course, this changed the paging behaviour for all the other git commands too, so I have used this shell function so that only git stash is affected:

# Override $LESS to print and exit with git stash
git() {
  if [[ $1 == stash ]]; then
    DELTA_PAGER='less -F' command git "$@"
  else
    command git "$@"
  fi
}