Wikia

Vim Tips Wiki

Changes: Script:3479

Edit

Back to page

(standard format)
(See also: add link to tip)
 
Line 44: Line 44:
 
==See also==
 
==See also==
 
*{{script|id=3431}} generic async facility; provides an "AsyncMake" command
 
*{{script|id=3431}} generic async facility; provides an "AsyncMake" command
  +
*Our tip on ways to [[Execute external programs asynchronously under Windows|execute asynchronous commands]] on your own.
   
 
==Comments==
 
==Comments==

Latest revision as of 15:41, December 6, 2011

Use this page to discuss script 3479 makebg: shell script to perform make in the background

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

SuggestionEdit

This is a really useful little script, but personally, I don't want to see any build output unless the build fails. As such, how about changing the script like this?

makeef="${3:-vimbuild.err}"
makeef="${makeef#$PWD/}"    # remove path, if present
makeprg="${2:-make}"
server="${1:-GVIM}"

{
  tempfile=`tempfile`
  > "$makeef";
  echo '-----------------------------------------' >> ".$makeef"
  date >> ".$makeef"
  echo '-----------------------------------------' >> ".$makeef"

  # run make, saving all output to a file, and recording exit code.
  exec 3<> $tempfile
  $makeprg >&3 2>&1
  rc=$?
  exec 3>&-

  # sed removes some words to prevent vim from misparsing a filename
  sed -e's/In file included from //' $tempfile >> ".$makeef";
  echo -e '\n\n' >> ".$makeef"
  cat "$makeef" >> ".$makeef"
  mv ".$makeef" "$makeef";
  if [ $rc -eq 0 ]
  then
    vim --servername "$server" --remote-send \
     '<Esc>:redraw | :echo "Build Successful"<CR>'
  else
    vim --servername "$server" --remote-send \
     "<Esc>:cgetfile $PWD/$makeef |copen<CR><CR>"
  fi

} &

Now, a successful will display "Build Successful", whereas a failing build will display the quickfix error window.

See alsoEdit

CommentsEdit

Around Wikia's network

Random Wiki