Skip to content

Instantly share code, notes, and snippets.

@Dkendal
Last active December 9, 2021 21:23
Show Gist options
  • Save Dkendal/4dd07a473954f6928626cd61a94bae26 to your computer and use it in GitHub Desktop.
Save Dkendal/4dd07a473954f6928626cd61a94bae26 to your computer and use it in GitHub Desktop.
interactive git log file searcher
function gzf -a file
function help
echo "usage: gzf <file>"
end
# echo $file
if ! string match '^\.\/'
set file "./$file"
end
set -l git_cmd "--no-pager show --minimal --patch --pretty=short --color=always"
set -l delta_opts "--relative-paths --hyperlinks --paging never --features side-by-side=false"
set -l preview "
git $git_cmd {1} $file | delta $delta_opts
"
if [ -z "$file" ]
help
return 1
end
set -l format "%C(yellow)%h%C(reset) %s %C(blue)(%S)%Creset"
set -l change "reload:args={q}; git log \$args --color=always --all --pretty='$format' -- '$file' || :"
git log --color=always --all --pretty="$format" -- "$file" |
fzf --ansi --disabled --preview "$preview" --bind "change:$change"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment