From 83769f73a12e8f5bfdbbef4fdbf9cdbc95ca5b32 Mon Sep 17 00:00:00 2001 From: Bart Brouns Date: Mon, 11 Dec 2017 06:01:48 +0100 Subject: [PATCH] add preview versions for fcoc and fshow --- Examples.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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