diff --git a/vim/vimrc.symlink b/vim/vimrc.symlink index ad854f4..724ec9c 100644 --- a/vim/vimrc.symlink +++ b/vim/vimrc.symlink @@ -101,6 +101,25 @@ endfunction nnoremap :exec ":e " . FindTestFilename(expand('%')) +" Run a given vim command on the results of fuzzy selecting from a given shell +" command. See usage below. +function! SelectaCommand(choice_command, selecta_args, vim_command) + try + let selection = system(a:choice_command . " | selecta " . a:selecta_args) + catch /Vim:Interrupt/ + " Swallow the ^C so that the redraw below happens; otherwise there will be + " leftovers from selecta on the screen + redraw! + return + endtry + redraw! + exec a:vim_command . " " . selection +endfunction + +" Find all files in all non-dot directories starting in the working directory. +" Fuzzy select one of those. Open the selected file with :e. +nnoremap t :call SelectaCommand("find * -type f", "", ":e") + " Git blame " " I used to do this by just filling in my buffer, but this is nicer.