dandavison / delta

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

Honor default-language option #1655

Closed imbrish closed 3 months ago

imbrish commented 3 months ago

Supersedes pull request #859. See also discussion #858. Fixes #499.

The actual code changes were made by @dandavison in that pull request, here I have only added tests.

Take diff:

diff --git a/abc b/abc
index 8c4ae06..0a37de7 100644
--- a/abc
+++ b/abc
@@ -9,7 +9,7 @@ foobar()
     dst=$(winpath $2)

     # List the directory.
-    ls -l $src
+    ls -la $src

     echo $src '->' $dst
     rsync -avu --delete $src/ $dst

And command:

cat diff | delta --no-gitconfig --default-language bash

Output before and after:

image

imbrish commented 3 months ago

The failing check is the usual test_env_parsing_with_pager_set_to_bat. All tests pass locally, and this is ready to merge.

dandavison commented 3 months ago

Excellent, thanks a lot!

For anyone looking to use this, one way is to add an entry like

[delta]
    default-language = bash

to your repo's .git/config (that way you can choose the language per-repo).