Skip to content

Instantly share code, notes, and snippets.

@akatrevorjay
Forked from junegunn/gist:f4fca918e937e6bf5bad
Last active May 19, 2024 01:39
Show Gist options
  • Save akatrevorjay/9fc061e8371529c4007689a696d33c62 to your computer and use it in GitHub Desktop.
Save akatrevorjay/9fc061e8371529c4007689a696d33c62 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=ctrl-s:toggle-sort
--preview 'f() { set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}"); [ $# -eq 0 ] || git show --color=always $1; }; f {}'
)
$g | $fzf
}
git-fshow "$@"
@netcookies
Copy link

thks for the script, it looks amazin

@akatrevorjay
Copy link
Author

@netcookies Anytime :)

@akatrevorjay
Copy link
Author

akatrevorjay commented Dec 10, 2017

If you like this, check out https://gist.github.com/akatrevorjay/06dc1238b2fcbfb6c10bbad05ad79bc1 -- similar integration for mlocate ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment