2

I wrote this little function to update my plugins from within vim:

function! UpdatePlugins()
  call system('for f in ~/.vim/bundle/*; do cd $f; git pull; done')
endfunction
command! UpdatePlugins call UpdatePlugins()

How can I get the output of this to be piped into a new buffer in real time? By real time, I mean this: If I were to run that system command in my shell, over the course of a few seconds each git pull would run and print lines to the standard output. I would like for those lines to be piped into a buffer as they are printed.

I know that I can do this to open a new buffer with the results:

function! UpdatePlugins()
  let x = system('for f in ~/.vim/bundle/*; do cd $f; git pull; done')
  tabnew
  put=x
endfunction
command! UpdatePlugins call UpdatePlugins()

But waiting for the pulls to complete is less than ideal.

2 Answers 2

3

You could simply do:

command! UpdatePlugins :!for f in ~/.vim/bundle/*; do cd $f; git pull; done<CR>

and see the output scroll in your shell.

1

Your UpdatePlugins() function could be this instead

function! UpdatePlugins()
    let x = system('for f in ~/.vim/bundle/*; do cd $f; git pull; done')
    call writefile(split(x, '\n'), 'vim_update_log.txt')
endfunction

This will write the output of system() into vim_update_log.txt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.