From aee838fefd2dd878915e14de0380731482b08e6d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 28 Mar 2018 00:50:47 +0200 Subject: git-blamer: Run `git show` on When the `` key is pressed in the GitBlamer window, run `!git show` on the commit from the current cursor line of the blame. This allows a changed line to be inspected in the context of its original changeset. It also saves me time from my previous workflow: cpe^Zgit show --- bundle/git-blamer/autoload/git_blamer.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'bundle/git-blamer/autoload') diff --git a/bundle/git-blamer/autoload/git_blamer.vim b/bundle/git-blamer/autoload/git_blamer.vim index df9832e..8245986 100644 --- a/bundle/git-blamer/autoload/git_blamer.vim +++ b/bundle/git-blamer/autoload/git_blamer.vim @@ -41,6 +41,7 @@ function! git_blamer#Blame() syncbind nnoremap q :q + nnoremap :call GitShow() " Restore starting file's scrollbind on exit autocmd BufWinLeave @@ -63,3 +64,12 @@ function! s:RemoveWindowFocusAutocmd() autocmd! augroup END endfunction + +function! s:GitShow() + execute '!git show ' . s:CommitSHAFromLine('.') +endfunction + +function! s:CommitSHAFromLine(line) + let current_line = getline(a:line) + return matchstr(current_line, '\v^[0-9a-f]+') +endfunction -- cgit v1.2.3