-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-commit-explore
More file actions
executable file
·24 lines (19 loc) · 957 Bytes
/
git-commit-explore
File metadata and controls
executable file
·24 lines (19 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env zsh
select_branch() {
echo $(git branch -v | fzf --prompt="$1" --ansi --no-sort --reverse |
tr -s ' ' | cut -d ' ' -f 2)
}
select_commit() {
echo $(git log "$2" --oneline |
fzf --prompt="$1" --ansi --no-sort --reverse \
--preview="echo {} | tr -s ' ' | cut -d ' ' -f 1 | \
xargs -I % git diff --patience --color=always %^..%" \
--bind="ctrl-u:preview-page-up" \
--bind="ctrl-d:preview-page-down" \
--bind="ctrl-k:preview-up" \
--bind="ctrl-j:preview-down" | tr -s ' ' | cut -d ' ' -f 1)
}
branch=${1:-$(select_branch '[Branch] > ')}
first=$(select_commit '[Base Commit] >' "$branch")
second=$(select_commit '[Compare Commit] >' "$branch")
git diff-explore "$first" "$second"