Last Updated: November 22, 2018
·
646
· azbshiri

Fastest way to search through files using git + fzy

function! FzyCommand(choice_command, vim_command)
  try
    let output = system(a:choice_command . " | fzy ")
  catch /Vim:Interrupt/
    " Swallow errors from ^C, allow redraw! below
  endtry
  redraw!
  if v:shell_error == 0 && !empty(output)
    exec a:vim_command . ' ' . output
  endif
endfunction

nnoremap <leader>p :call FzyCommand("git ls-files --cached --exclude-standard --others", ":e")<cr>