git: add git-delta as diff pager

This commit is contained in:
Fernando Schauenburg 2023-07-12 19:52:39 +02:00
parent 1c613b082d
commit 581c7d07e4
3 changed files with 51 additions and 1 deletions

7
bin/delta-wrapper Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
# This wrapper is intended to be used as pager for git:
# - Use `git-delta` if installed.
# - Otherwise, fall back to `less`.
command -v delta >/dev/null 2>&1 && exec delta --true-color=always "$@"
exec less -F -X "$@"

View file

@ -22,7 +22,7 @@
[core] [core]
excludesfile = ~/.config/git/ignore excludesfile = ~/.config/git/ignore
trustctime = false # http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/ trustctime = false # http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/
pager = less -F -X pager = delta-wrapper
[init] [init]
defaultBranch = main defaultBranch = main
@ -30,14 +30,39 @@
[log] [log]
date = human date = human
[delta]
navigate = true # use n and N to navigate diff secitons
commit-decoration-style = "#b58900" box
commit-style = raw
dark = true
file-decoration-style = "#268bd2" box ul
file-style = "#268bd2"
hunk-header-style = omit
line-numbers = true
line-numbers-minus-style = "#dc322f" italic
line-numbers-plus-style = "#719e07" italic
line-numbers-left-style = "#586e75"
line-numbers-right-style = "#eee8d5"
line-numbers-zero-style = "#073642"
minus-emph-style = normal "#842b2c"
minus-style = normal "#2c2429"
plus-emph-style = syntax "#446c14"
plus-style = syntax "#173921"
syntax-theme = Nord
[push] [push]
default = upstream default = upstream
[pull] [pull]
ff = only ff = only
[diff]
colorMoved = default
[merge] [merge]
tool = vimdiff tool = vimdiff
conflictstyle = diff3
[mergetool] [mergetool]
prompt = false prompt = false

View file

@ -4,6 +4,7 @@ set -e
USERNAME=fernando USERNAME=fernando
DOTFILES_URL="https://github.com/fschauen/dotfiles.git" DOTFILES_URL="https://github.com/fschauen/dotfiles.git"
NEOVIM_VERSION="0.9.1" NEOVIM_VERSION="0.9.1"
GIT_DELTA_VERSION="0.16.5"
if [ -t 1 ]; then if [ -t 1 ]; then
sgr0="$(printf '\033[0m')" sgr0="$(printf '\033[0m')"
@ -113,6 +114,20 @@ install_neovim() {
fi fi
} }
install_git_delta() {
delta_url="https://github.com/dandavison/delta/releases/download/${GIT_DELTA_VERSION}/git-delta-musl_${GIT_DELTA_VERSION}_amd64.deb"
delta_deb="git-delta-musl_${GIT_DELTA_VERSION}_amd64.deb"
delta_bin="/usr/bin/delta"
if [ ! -f "${delta_bin}" ]; then
[ ! -f "${delta_deb}" ] && $cmd curl -L -o "${delta_deb}" "${delta_url}"
$cmd dpkg -i "${delta_deb}"
$cmd rm -vf "${delta_deb}"
else
echo "${yellow}SKIPPED:${sgr0} ${delta_bin} exists"
fi
}
setup_user() { setup_user() {
# Change shell to `zsh` and get rid of bash files. # Change shell to `zsh` and get rid of bash files.
$cmd chsh -s /bin/zsh "$USERNAME" $cmd chsh -s /bin/zsh "$USERNAME"
@ -149,6 +164,9 @@ execute() {
heading "Install neovim v$NEOVIM_VERSION" heading "Install neovim v$NEOVIM_VERSION"
install_neovim # Must come after filesystem tweaks because of man pages. install_neovim # Must come after filesystem tweaks because of man pages.
heading "Install git-delta v$GIT_DELTA_VERSION"
install_git_delta
heading "Setup user: $USERNAME" heading "Setup user: $USERNAME"
setup_user setup_user