git rev-parseの結果でその後のコマンドの内容を変えている。
exit statusが取れればrev-parseじゃなくても良さそうだけど、方法がわからなかった。
function! IsInsideWorkTree()
let l:is_inside = system('git rev-parse --is-inside-work-tree')
return l:is_inside == "true\n" ? 1 : 0
endfunction
function! UniteFileRecSource()
if IsInsideWorkTree()
Unite file_rec/git
else
Unite file_rec/async
endif
endfunction
key bind
nnoremap [unite] <Nop>
nmap <space>f [unite]
xmap <space>f [unite]
nnoremap <silent> [unite]r :<C-u>call UniteFileRecSource()<CR>