Archive for the ‘bash’ Category

Redirect build errors into vim

Thursday, December 10th, 2009

Here is a small bash function which wraps the executed command in the shell and redirects all build errors right into vim. In vim you can jump between errors using standard :cn,:cp commands(as well as view them all using :cope).

function vimize () 
{ 
  local file=/tmp/vimize.errors
  if [ "$1" != "" ] ; then
    rm $file 2> /dev/null
    $1 "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" 2>&1 | tee $file
  fi
  grep ': error:' $file 
  if [ "$?" == "0" ] ; then
    vim -q $file -c :copen
  fi
}

Just put it into your ~/.bashrc, reload the shell and ejoy it. It can be used as follows:

$ vimize ./run_some_build_script