Created
October 16, 2022 12:38
-
-
Save maguroguma/4ebce74f514c8a3a1711ad4a2e29d988 to your computer and use it in GitHub Desktop.
print the selected revision of current buffer file (require fzf.vim and fugitive.vim)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" source | |
function! s:list_commits() abort | |
let l:res = system('git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --color=always') | |
return split(l:res, "\n") | |
endfunction | |
" sink | |
function! s:select_commits(commit_hash) abort | |
let l:list = split(a:commit_hash, ' ') | |
let l:execute_command = 'Git show ' . l:list[1] . ':%' | |
execute l:execute_command | |
endfunction | |
command! GShow call fzf#run(fzf#wrap({ | |
\ 'source': s:list_commits(), | |
\ 'sink': funcref('s:select_commits'), | |
\ 'options': '--ansi --prompt "git show of the buffer> "', | |
\ })) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment