Skip to content

Instantly share code, notes, and snippets.

@AksAman
Last active May 24, 2023 23:29
Show Gist options
  • Select an option

  • Save AksAman/a8b48c77bf8b24e983211a5bef49ce28 to your computer and use it in GitHub Desktop.

Select an option

Save AksAman/a8b48c77bf8b24e983211a5bef49ce28 to your computer and use it in GitHub Desktop.
Alias to view git log in a pretty way with fuzzy search and files preview using fzf
# fzf from https://github.com/junegunn/fzf
# diff-so-fancy from https://github.com/so-fancy/diff-so-fancy
gcop() {
git log \
--reverse \
--color=always \
--format="%C(cyan)%h %C(blue)%ar%C(auto)%d% C(yellow)%s%+b %C(magenta)%ae" "$@" |
fzf -i -e +s \
--reverse \
--tiebreak=index \
--no-multi \
--ansi \
--preview="echo {} |
grep -o '[a-f0-9]\{7\}' |
head -1 |
xargs -I % sh -c 'git show --color=always % |
diff-so-fancy'" \
--header "enter view, C-c: copy hash" \
--bind "enter:execute:$_viewGitLogLine | less -R"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment