Fandom

Vim Tips Wiki

Script:3479

1,624pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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

Also on Fandom

Random Wiki