Hi. I've written another little script.. But by now you need sh and a
client-server version. Perhaps you like it?

just run

gvim --servername  MYSERVERNAME

and run a backgroundtask, eg

==== takealotoftime.sh =====
#!/bin/sh
sleep 2
echo "I'm ready soon"
sleep 3
echo "I will take long"
sleep 1
==== takealotoftime.sh =====

:call RunMakeCommandInBackground("./takealotoftime.sh")

Ah.. and set the colorschemes to values you have installed

=================================================
" This script is designed to run a command (eg make) 
" in background only works if vim is compiled with 
" clientserver feature

let s:normal_colorscheme=g:colors_name"
let s:workinbackground_colorscheme="lilac"

let s:tempfile=tempname()

" add your tasks here
fun BackgroundJobHasStarted()
  exec 'colorscheme '.s:workinbackground_colorscheme
endfun

" add your tasks here
fun BackgroundJobHasFinisheed()
  exec 'cfile '.s:tempfile
  exec 'colorscheme '.s:normal_colorscheme
endfun

fun CommandHasFinished()
  call BackgroundJobHasFinisheed()
endfun

fun RunMakeCommandInBackground(cmd)
  if !has('clientserver') 
    echoe "no client-server version"
  endif
  if has('gui-running') " FIXME: get vim executable name insteadn (cargs 0)
    let vim="gvim"
  else
    let vim="vim"
  endif
  let vim="/usr/bin/gvim"

  let cmd="sh -c '".a:cmd." > ".s:tempfile."; ".vim." --servername 
\"".v:servername."\" --remote-send \":call CommandHasFinished()<cr>\"'"
  "exec ":!".cmd." &"
  call system(cmd." &")
  call BackgroundJobHasStarted()
endfun
=================================================

How do you like it?
Some improvements could be made to pass the exit code, too.

Marc

Reply via email to