Browse Source

Majke possible to use detla as git pager

Emmanuel Bouthenot 1 year ago
parent
commit
d6c2783e08
2 changed files with 21 additions and 4 deletions
  1. 7 0
      tools/git/.gitconfig
  2. 14 4
      zsh/zshrc

+ 7 - 0
tools/git/.gitconfig

@@ -35,3 +35,10 @@
 
 [pager]
     diff = true
+
+[delta]
+    features = dotfiles-sys
+
+[delta "dotfiles-sys"]
+    syntax-theme = Nord
+    line-numbers = true

+ 14 - 4
zsh/zshrc

@@ -74,8 +74,13 @@ COLOR_RESET="$terminfo[sgr0]"
 # Pager
 #
 
-VIMPAGER="$(readlink -f "${ZDOTDIR}/../tools/vimpager/vimpager")"
-if (( $+commands[vim] )) && [[ -f "${VIMPAGER}" ]]; then
+if (( $+commands[batcat] )); then
+    export PAGER=batcat
+    alias less="${PAGER}"
+    alias more="${PAGER}"
+elif (( $+commands[vim] )) && [[ -f "${VIMPAGER}" ]]; then
+    VIMPAGER="$(readlink -f "${ZDOTDIR}/../tools/vimpager/vimpager")"
+
     export PAGER="${VIMPAGER}"
     alias less="${PAGER}"
     alias more="${PAGER}"
@@ -83,14 +88,14 @@ if (( $+commands[vim] )) && [[ -f "${VIMPAGER}" ]]; then
     if [[ ! -f "${VIMPAGER_RC}" ]]; then
         unset VIMPAGER_RC
     fi
+
+    unset VIMPAGER
 elif (( $+commands[less] )); then
     export PAGER=less
     alias more="${PAGER}"
 elif (( $+commands[more] )); then
     export PAGER=more
 fi
-export GIT_PAGER="${PAGER}"
-unset VIMPAGER
 
 #
 # Vim
@@ -110,6 +115,10 @@ fi
 # Git
 #
 
+if (( $+commands[delta] )); then
+    export GIT_PAGER=delta
+fi
+
 GIT_OPTIONS=()
 if [[ -n "${LC_SSH_FULLNAME}" ]]; then
     GIT_OPTIONS+=(-c "user.name=${LC_SSH_FULLNAME}")
@@ -125,6 +134,7 @@ export GIT_OPTIONS
 
 git() {
     (
+        export PAGER=less
         export GIT_FAKE_HOME="$(readlink -f "${ZDOTDIR}/../tools/git")"
         if [[ -f "${GIT_FAKE_HOME}/.gitconfig" ]]; then
             export HOME="${GIT_FAKE_HOME}"