/
git-pager
executable file
·46 lines (40 loc) · 1.19 KB
/
git-pager
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
export GIT_PAGER="less $LESS -F -S"
GIT_PAGER="${GIT_PAGER/ -j[0-9] / }"
GIT_PAGER="${GIT_PAGER/ -j[0-9][0-9] / }"
GIT_PAGER="${GIT_PAGER/-a / }"
git_diff_highlight=
case "$GIT_PAGER_MODE" in
log)
git_pager_regexp='^commit [0-9a-f]{7}.*'
git_diff_highlight=y
;;
diff)
# ggsh could be showing a merge commit
git_pager_regexp='^(diff|commit) .*'
git_diff_highlight=y
;;
commit)
git_pager_regexp='^(commit [0-9a-f]{7}.*|diff .*)'
git_diff_highlight=y
;;
oneline)
# FIXME: what's the idea behind this?
git_pager_regexp='^[0-9a-f]{7}[0-9a-f]*'
;;
default|"")
#git_pager_regexp='^(commit [0-9a-f]{7}.*|diff .*|[0-9a-f]{7}[0-9a-f]*)'
unset git_pager_regexp
;;
none)
unset git_pager_regexp
GIT_PAGER=""
;;
*)
echo "ERROR: unrecognised value for GIT_PAGER_MODE [$GIT_PAGER_MODE]" >&2
;;
esac
[ -n "$git_pager_regexp" ] && GIT_PAGER="$GIT_PAGER +/'$git_pager_regexp'"
if which diff-highlight >/dev/null 2>&1; then
[ -n "$git_diff_highlight" ] && [ -n "$GIT_PAGER" ] && GIT_PAGER="diff-highlight | $GIT_PAGER"
fi