git: Make git diff termcolor aware

Added simple light/dark distinction for git diffs using delta.
Will use the TERM_DARK env variable which is set in the base
module functionality on opening a new term.

This means unfortunately git diffs will have the wrong color
when terms recently changed between light-dark but on opening
a new one the error is gone and it automatically adapts again
to the terminal background color.
This commit is contained in:
Marty Oehme 2023-12-12 12:19:41 +01:00
parent 62ec2799c8
commit b6687145bd
Signed by: Marty
GPG Key ID: EDBF2ED917B2EF6A
2 changed files with 14 additions and 11 deletions

View File

@ -5,17 +5,17 @@
[init]
defaultBranch = main
[core]
pager = delta
pager = git delta
[pager]
difftool = true
[interactive]
diffFilter = delta --color-only
diffFilter = git delta --color-only
[merge]
conflictstyle = diff3
[delta]
navigate = true
line-numbers = true
syntax-theme = base16
navigate = true
line-numbers = true
syntax-theme = base16
[sendemail]
smtpserver = "/usr/bin/msmtp"
annotate = yes
@ -27,6 +27,7 @@
diffword = "!git diff --word-diff=color --word-diff-regex='[0-9A-Za-z_]+'" # word-wise diff, good for prose
diffsyn = "!git difftool --tool difftastic" # add syntax-driven diff using treesitter
diffside = "!DELTA_FEATURES='+side-by-side' git diff" # add side-by-side diffing
delta = "![ $TERM_DARK=false ] && delta --light || delta" # Take care that we always display right color scheme
[commit]
gpgsign = true # sign commits as me
verbose = true # Always show diff when preparing commit message

View File

@ -31,13 +31,11 @@ else
fi
alias gco='git checkout'
alias gd='git diff'
alias gdd='git diffword'
alias gds='git diff --staged'
alias gdds='git diffword --staged'
alias gi='git ignore'
# normal diff
alias gd='git diff'
alias gds='git diff --staged'
# word-based diff (with custom word regex)
alias gdw='git diffword'
alias gdws='git diffword --staged'
@ -49,12 +47,16 @@ if exist difft; then
alias gdy='git diffsyn'
alias gdys='git diffsyn --staged'
fi
alias gdd='git diffside'
alias gdds='git diffside --staged'
# show last committed content
alias gdl='git last'
# show quick log overview
alias glg='git log --oneline --decorate --graph'
alias glgd="git log --graph --pretty=format:'%C(auto)%h%Creset %C(cyan)%ar%Creset%C(auto)%d%Creset %s'"
alias glga='git log --oneline --decorate --graph --remotes --all'
# show quick log overview - with dates
alias glgd="git log --graph --pretty=format:'%C(auto)%h%Creset %C(cyan)%ar%Creset%C(auto)%d%Creset %s'"
alias glgad="git log --graph --remotes --all --pretty=format:'%C(auto)%h%Creset %C(cyan)%ar%Creset%C(auto)%d%Creset %s'"
# show detailed log overview
alias glog='git log --stat'