Skip to content

Instantly share code, notes, and snippets.

@srijanshetty
Forked from akatrevorjay/git-fshow
Last active May 28, 2019 20:36
Show Gist options
  • Save srijanshetty/3017fbab6569f3e76e19c3c868eb0963 to your computer and use it in GitHub Desktop.
Save srijanshetty/3017fbab6569f3e76e19c3c868eb0963 to your computer and use it in GitHub Desktop.
Browsing git commit history with fzf
#!/bin/zsh
# git-fshow - git commit browser
#
# https://gist.github.com/akatrevorjay/9fc061e8371529c4007689a696d33c62
# https://asciinema.org/a/101366
#
git-fshow() {
local g=(
git log
--graph
--format='%C(auto)%h%d %s %C(white)%C(bold)%cr'
--color=always
"$@"
)
local fzf=(
fzf
--ansi
--reverse
--tiebreak=index
--no-sort
--bind=J:preview-down,K:preview-up,ctrl-f:preview-page-down,ctrl-b:preview-page-up,q:abort
--preview 'f() { set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}"); [ $# -eq 0 ] || git show --color=always $1; }; f {}'
)
$g | $fzf
}
git-fshow "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment