dandavison / delta

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

Somehow I have to `git diff | delta` to make it work #337

Closed zachliu closed 4 years ago

zachliu commented 4 years ago

I installed delta and set up everything in my .gitconfig but it didn't work out of the box. I have to pipe git diff into delta manually. Here is some relevant info:

delta 0.4.3
git version 2.25.1
less 551 (POSIX regular expressions)

and my .gitconfig:

[user]
  name = zachliu

[core]
  editor = nvim
  autocrlf = input
  safecrlf = true
  pager = delta

[alias]
  hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
  type = cat-file -t
  dump = cat-file -p

[pull]
  rebase = true

[delta]
  plus-style =  syntax "#214f11" # set background color
  syntax-theme = Monokai Extended
  dark = true
  side-by-side = true

[interactive]
  diffFilter = delta --color-only
dandavison commented 4 years ago

Hi @zachliu, hm, maybe git isn't finding your delta executable? Try typing which delta at the command line and then using that absolute path as the value for core.pager. To double check what git is finding in the config, you can do

git config --get core.pager
zachliu commented 4 years ago

Tried. Now i have

$ which delta
/usr/bin/delta

and

$ git config --get core.pager
/usr/bin/delta

but git diff still doesn't use delta :crying_cat_face:

dandavison commented 4 years ago

OK, let's get to the bottom of this! What about if you do

[core]
    pager = bash -c 'echo Hello, world!'

That should result in

$ git show
Hello, world!

If that works as expected, what about if you do

[core]
    pager = delta > /tmp/delta.out 2> /tmp/delta.err

Does that create the files? Is there an error?

zachliu commented 4 years ago

found the problem! something is setting the env var GIT_PAGER=less somewhere the damn thing is i can't seem to find the something and the somewhere :facepalm:

dandavison commented 4 years ago

OK, great! Hm, good luck finding that. Not an oh-my-zsh plugin or something like that?

zachliu commented 4 years ago

It turns out tmux is persisting my already-commented-out export GIT_PAGER=less in .zshrc all i needed to do was to restart tmux ¯\_(ツ)_/¯