-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglog
More file actions
executable file
·23 lines (21 loc) · 958 Bytes
/
glog
File metadata and controls
executable file
·23 lines (21 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/zsh
# Git log but pretty and with fzf and bat preview
# NOTE: just use "git forgit log" instead (does same thing but better)
glog() {
git log \
--graph \
--color=always \
--format="%C(auto)%h%d %s %C(blue)%C(bold)%cr" "$@" |
fzf \
--ansi \
--no-sort \
--reverse \
--tiebreak=index \
--toggle-sort=\` \
--preview "echo '{}' | grep -o '[a-f0-9]\{7\}' | head -1 | xargs -I % sh -c 'git show --color=always % | delta | bat'" \
--header="ENTER to view, CTRL-Y to copy hash to xclip, CTRL-X to checkout commit" \
--bind "enter:execute:echo '{}' | grep -o '[a-f0-9]\{7\}' | head -1 | xargs -I % sh -c 'git show --color=always % | delta | bat'" \
--bind "ctrl-y:execute:echo {} | grep -o '[a-f0-9]\{7\}' | head -1 | xclip" \
--bind "ctrl-x:execute:echo '{}' | grep -o '[a-f0-9]\{7\}' | head -1 | xargs -I % sh -c 'git checkout %'" \
}
glog "$@"