0

I do some automatic setup in my vimrc that calls git clone, before any other plugins (such as dispatch.vim) are installed. It's called after some other messages are displayed using echom, and I'd like to to execute without clearing the screen at all. I've been messing around with redir, shellredir and shortmess, but nothing has worked so far:

" some other messages are displayed and in the buffer ...

" install neobundle
if $HAS_GIT == 1

  " display the inline message notifying user neobundle is being installed,
  " I want this to displayed inline with the other messages
  echom 'installing neobundle ...'

  " trying to use shellredir to temporarily disable external command
  " from displaying any output and causing the screen refresh - doesn't work
  let shellredir_restore = &shellredir
  let &shellredir = '>/dev/null'

  " trying to use redir to temporarily disable external command
  " from displaying any output and causing the screen refresh - doesn't work
  redir >> /dev/null

  " silently execute git clone as a synchronous task - desired behavior. 
  silent execute '!git clone ' g:neobundle_url . ' ' . g:neobundle_dir . '&>/dev/null'

  " once this command completes, the screen is cleared and additional
  " 'inline' messages (that should be displayed) are, but with the
  " previous messages removed. all output after this point is written at
  " the *bottom* of the buffer.

  " end vim output redirection
  redir END

  " check if git clone completely successfully
  if v:shell_error == 0
    let s:neobundle_installed = 1
  else
    let s:neobundle_installed = 0
  endif

  " restore shellredir to original value
  let &shellredir = shellredir_restore

endif

So to clarify:

  • i want to suppress all output from git clone
  • i want to prevent the refresh by the git clone, which clears previous messages
  • i want additional messages after the git clone to be drawn 'inline' as normal, not at the bottom of the screen

Any suggestions?

1 Answer 1

4

For running git without screen refreshes I suggest leaving alone all shell-related options and redirs, and doing it like this:

let s:neobundle_installed = 0
if executable('git')
    call system('git clone ' . shellescape(g:neobundle_url) . ' ' . shellescape(g:neobundle_dir))
    let s:neobundle_installed = v:shell_error == 0
endif

I have no idea what you mean by "additional messages", and by "drawing" them "inline".

1
  • By 'inline' I was just referring to having the normal messages written to the existing buffer without any modifications (like screen redraws, or empty spaces that pushes additional messages to the bottom of the screen). In any case, your solution works, thank you!
    – nfarrar
    May 24, 2015 at 17:23

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.