Skip to content

Commit c0292b4

Browse files
author
Bhavi Dhingra
committed
feat(gdiff): use delta as git's core pager
1 parent c40b9f0 commit c0292b4

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

util/__common

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
#shellcheck disable=SC2034 # CUSTOM_GIT_PAGER appears unused. Verify use (or export if used externally)
4+
5+
CUSTOM_GIT_PAGER="$(git config core.pager || echo 'cat')"

util/fzf_previews/__gdiff_preview

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#shellcheck disable=SC2155
44
#shellcheck disable=SC1091
55

6+
source "${__CUSTOM_GIT_UTIL}"/__common
67
source "$__CUSTOM_CONSOLE_UTIL"/__split_str
78
source "$__CUSTOM_CONSOLE_UTIL"/__trim_double_quotes
89

@@ -15,10 +16,10 @@ function __gdiff_preview() {
1516
file="$(__trim_double_quotes "${file}")"
1617

1718
if [[ ${str:0:1} != " " ]];then # file is staged
18-
git diff --cached --color -- "${file}"
19+
git diff --cached --color -- "${file}" | ${CUSTOM_GIT_PAGER}
1920
fi
2021
if [[ ${str:1:1} != " " ]];then # file is unstaged
21-
git diff --color -- "${file}"
22+
git diff --color -- "${file}" | ${CUSTOM_GIT_PAGER}
2223
fi
2324
return
2425
fi
@@ -37,12 +38,12 @@ function __gdiff_preview() {
3738
done
3839

3940
if [[ ${str:0:1} == "R" ]]; then
40-
git diff --cached --color -- "${oldFile}" "${newFile}"
41+
git diff --cached --color -- "${oldFile}" "${newFile}" | ${CUSTOM_GIT_PAGER}
4142

4243
if [[ ${str:1:1} != " " ]]; then
43-
git diff --color -- "${newFile}"
44+
git diff --color -- "${newFile}" | ${CUSTOM_GIT_PAGER}
4445
fi
4546
else
46-
git diff --color -- "${oldFile}" "${newFile}"
47+
git diff --color -- "${oldFile}" "${newFile}" | ${CUSTOM_GIT_PAGER}
4748
fi
4849
}

util/fzf_previews/__gshow_preview

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22

33
#shellcheck disable=SC2155
4+
#shellcheck disable=SC1091 # Not following: ./__common was not specified as input (see shellcheck -x)
5+
6+
source "${__CUSTOM_GIT_UTIL}"/__common
47

58
function __gshow_preview() {
69

@@ -9,5 +12,5 @@ function __gshow_preview() {
912
if [[ -z "${commitSHA}" ]]; then
1013
return
1114
fi
12-
git show --color=always "${commitSHA}"
15+
git show --color=always "${commitSHA}" | ${CUSTOM_GIT_PAGER}
1316
}

0 commit comments

Comments
 (0)