-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-choose-commit
More file actions
executable file
·74 lines (61 loc) · 1.59 KB
/
git-choose-commit
File metadata and controls
executable file
·74 lines (61 loc) · 1.59 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env zsh
#
# Note:
#
# This script will use `pretty.fzf` for log format, if one is configured in git.
#
# The git log format should contain two fields separated by Unit Separator (U+001F):
#
# 1. The commit itself that fzf will show to the user.
# 2. The commit hash that fzf will use to return to the user and use in the preview command.
#
# Individual commits will be separated by a NUL character (U+0000) so newlines are supported.
#
git_log_format_default='tformat:%h% t% ad% aE%+s%+D%n%x1F%H'
git_log_args=(
--graph
-z
--pretty="${"${"$(git config --get pretty.fzf)":+"fzf"}":-"$git_log_format_default"}"
"$@"
)
typeset -A git_configs_kv
git_configs_kv=(
[color.ui]='always'
)
export GIT_CONFIG_COUNT=0
for key value in "${(@kv)git_configs_kv}"; do
export GIT_CONFIG_KEY_"$((GIT_CONFIG_COUNT))"="$key"
export GIT_CONFIG_VALUE_"$((GIT_CONFIG_COUNT))"="$value"
export GIT_CONFIG_COUNT="$((GIT_CONFIG_COUNT + 1))"
done
unset git_configs_kv
preview_command='
if (( $FZF_PREVIEW_COLUMNS >= 140 )); then
export DELTA_FEATURES='+side-by-side'
fi
git show \
--pretty=fuller \
--date="format-local:%a %m/%d/%Y %H:%M:%S %z" {2} \
| \
delta "$DELTA_DARK_OR_LIGHT" --width=$FZF_PREVIEW_COLUMNS
'
source "${0:h}/query-terminal.zsh"
export DELTA_DARK_OR_LIGHT=$(
query_terminal_luminance --dark --light
)
fzf_args=(
--read0
--delimiter $'\x1F'
--with-nth 1
--accept-nth 2
--reverse
--no-sort
--ansi
--wrap
--highlight-line
--with-shell 'zsh -c'
--bind 'resize:refresh-preview'
--preview-window wrap
--preview "$preview_command"
)
git log "${git_log_args[@]}" | fzf "$fzf_args[@]"