Last active
March 5, 2018 01:23
-
-
Save rsrchboy/42fa288e65741500819c6341bde5caa5 to your computer and use it in GitHub Desktop.
blog post -- fzf project snippets
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
fun! rsrchboy#fzf#FindOrOpenTab(work_dir) abort | |
" loop over our tabs, looking for one with a t:git_workdir matching our | |
" a:workdir; if found, change tab; if not fire up fzf again to find a file | |
" to open in the new tab | |
for l:tab in (gettabinfo()) | |
if get(l:tab.variables, 'git_workdir', '') ==# a:work_dir | |
exe 'tabn ' . l:tab.tabnr | |
return | |
endif | |
endfor | |
call fzf#run(fzf#wrap('other-repo-git-ls', { | |
\ 'source': 'git ls-files', | |
\ 'dir': a:work_dir, | |
\ 'options': '--prompt "GitFiles in ' . a:work_dir . '> "', | |
\ 'sink': 'tabe ', | |
\}, 0)) | |
return | |
endfun |
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
command! -nargs=0 Projects | |
\ call fzf#run(fzf#wrap('projects', { | |
\ 'source': 'find ~/work ~/.vim/plugged -name .git -maxdepth 3 -printf ''%h\n''', | |
\ 'sink': function('rsrchboy#fzf#FindOrOpenTab'), | |
\ 'options': '-m --prompt "Projects> "', | |
\}, <bang>0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment