/
dirvish.vim
41 lines (36 loc) · 1004 Bytes
/
dirvish.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
" See: ../../ftplugin/dirvish.vim
" See: https://github.com/MaxMEllon/.vim/blob/master/autoload/maxmellon/dirvish.vim
function! maxmellon#dirvish#touch(filename) abort
execute 'cd ' . expand('%')
execute '!touch ' . a:filename
edit %
endfunction
function! maxmellon#dirvish#mkdir(filename) abort
execute 'cd ' . expand('%')
execute '!mkdir ' . a:filename
edit %
endfunction
function! maxmellon#dirvish#mv(...) abort
if len(a:000) != 2 | return | endif
execute 'cd ' . expand('%')
execute '!mv ' . a:1 . ' ' . a:2
edit %
endfunction
function! maxmellon#dirvish#rm(...) abort
if len(a:000) == 0 | return | endif
execute 'cd ' . expand('%')
for s:file in a:000
execute '!rm ' . s:file
endfor
edit %
endfunction
function! maxmellon#dirvish#cdgitroot() abort
call maxmellon#cdgitroot#exec()
redir => s:output
pwd
redir END
if &filetype ==# 'dirvish'
let s:output = substitute(s:output, '[\r\n]', '', 'g')
execute 'edit ' . s:output
endif
endfunction