Skip to content

Instantly share code, notes, and snippets.

@motemen
Created March 30, 2011 11:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motemen/894232 to your computer and use it in GitHub Desktop.
Save motemen/894232 to your computer and use it in GitHub Desktop.
highlight last change on git
" requires metarw-git
nnoremap <silent> <Leader>gw :silent call GitHighlightLastChange()<CR>
function! GitHighlightLastChange()
if &diff
diffoff
return
endif
let log = system('git log -1 --pretty=oneline ' . expand('%'))
if v:shell_error
echoerr log
return
endif
let [ sha1, message ] = matchlist(log, '\v(\x{40}) (.*)\n')[1:2]
execute 'vertical diffsplit' 'git:' . sha1 . '^:%'
quit
redrawstatus
unsilent echo "highlighting diff of '" . message . "'"
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment