4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git管理下ならfile_rec/gitを使い、その他はfile_rec/asyncを使う

Last updated at Posted at 2015-12-14

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>
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?