diff --git a/Examples.md b/Examples.md index e0258fc..7add54e 100644 --- a/Examples.md +++ b/Examples.md @@ -428,6 +428,30 @@ fshow() { FZF-EOF" } ``` +```sh +alias glNoGraph='git log --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr% C(auto)%an" "$@"' +local _gitLogLineToHash="echo {} | grep -o '[a-f0-9]\{7\}' | head -1" +local _viewGitLogLine="$_gitLogLineToHash | xargs -I % sh -c 'git show --color=always % | diff-so-fancy'" + +# fcoc_preview - checkout git commit with previews +fcoc_preview() { + local commit + commit=$( glNoGraph | + fzf --no-sort --reverse --tiebreak=index --no-multi \ + --preview $_viewGitLogLine ) && + git checkout $(echo "$commit" | sed "s/ .*//") +} + +# fshow_preview - git commit browser with previews +fshow_preview() { + glNoGraph | + fzf --no-sort --reverse --tiebreak=index --no-multi \ + --preview $_viewGitLogLine \ + --header "enter to view, alt-y to copy hash" \ + --bind "enter:execute:$_viewGitLogLine | less -R" \ + --bind "alt-y:execute:$_gitLogLineToHash | xclip" +} +``` ```sh # fcs - get git commit sha