From b6687145bd96a5fe411f05b6802d69ba5c7799db Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 12 Dec 2023 12:19:41 +0100 Subject: [PATCH] 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. --- git/.config/git/config | 11 ++++++----- git/.config/sh/alias.d/git.sh | 14 ++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/git/.config/git/config b/git/.config/git/config index 6e430d9..fa694ae 100644 --- a/git/.config/git/config +++ b/git/.config/git/config @@ -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 diff --git a/git/.config/sh/alias.d/git.sh b/git/.config/sh/alias.d/git.sh index 44dc57b..734f837 100644 --- a/git/.config/sh/alias.d/git.sh +++ b/git/.config/sh/alias.d/git.sh @@ -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'