diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp
index a6b6dd7511254ead271e4ab80b9bb990e58aaa08..250b524b087698d52fba85edba0f52b8753b7e2e 100644
--- a/Common/GmshMessage.cpp
+++ b/Common/GmshMessage.cpp
@@ -155,6 +155,42 @@ void Msg::Exit(int level)
   exit(_errorCount);
 }
 
+static int streamIsFile(FILE* stream)
+{
+  // the given stream is definately not interactive if it is a regular file
+  struct stat stream_stat;
+  if(fstat(fileno(stream), &stream_stat) == 0){
+    if(stream_stat.st_mode & S_IFREG) return 1;
+  }
+  return 0;
+}
+
+static int streamIsVT100(FILE* stream)
+{
+  // if running inside emacs the terminal is not VT100
+  const char* emacs = getenv("EMACS");
+  if(emacs && *emacs == 't') return 0;
+
+  // list of known terminal names (from cmake)
+  static const char* names[] =
+    {"Eterm", "ansi", "color-xterm", "con132x25", "con132x30", "con132x43",
+     "con132x60", "con80x25",  "con80x28", "con80x30", "con80x43", "con80x50",
+     "con80x60",  "cons25", "console", "cygwin", "dtterm", "eterm-color", "gnome",
+     "gnome-256color", "konsole", "konsole-256color", "kterm", "linux", "msys",
+     "linux-c", "mach-color", "mlterm", "putty", "rxvt", "rxvt-256color",
+     "rxvt-cygwin", "rxvt-cygwin-native", "rxvt-unicode", "rxvt-unicode-256color",
+     "screen", "screen-256color", "screen-256color-bce", "screen-bce", "screen-w",
+     "screen.linux", "vt100", "xterm", "xterm-16color", "xterm-256color",
+     "xterm-88color", "xterm-color", "xterm-debian", 0};
+  const char** t = 0;
+  const char* term = getenv("TERM");
+  if(term){
+    for(t = names; *t && strcmp(term, *t) != 0; ++t) {}
+  }
+  if(!(t && *t)) return 0;
+  return 1;
+}
+
 void Msg::Fatal(const char *fmt, ...)
 {
   _errorCount++;
@@ -183,10 +219,14 @@ void Msg::Fatal(const char *fmt, ...)
 #endif
 
   if(CTX::instance()->terminal){
+    const char *c0 = "", *c1 = "";
+    if(!streamIsFile(stderr) && streamIsVT100(stderr)){
+      c0 = "\33[31m"; c1 = "\33[0m";  // red
+    }
     if(_commSize > 1)
-      fprintf(stderr, "Fatal   : [On processor %d] %s\n", _commRank, str);
+      fprintf(stderr, "%sFatal   : [On processor %d] %s%s\n", c0, _commRank, str, c1);
     else
-      fprintf(stderr, "Fatal   : %s\n", str);
+      fprintf(stderr, "%sFatal   : %s%s\n", c0, str, c1);
     fflush(stderr);
   }
 
@@ -219,10 +259,14 @@ void Msg::Error(const char *fmt, ...)
 #endif
 
   if(CTX::instance()->terminal){
+    const char *c0 = "", *c1 = "";
+    if(!streamIsFile(stderr) && streamIsVT100(stderr)){
+      c0 = "\33[31m"; c1 = "\33[0m";  // red
+    }
     if(_commSize > 1)
-      fprintf(stderr, "Error   : [On processor %d] %s\n", _commRank, str);
+      fprintf(stderr, "%sError   : [On processor %d] %s%s\n", c0, _commRank, str, c1);
     else
-      fprintf(stderr, "Error   : %s\n", str);
+      fprintf(stderr, "%sError   : %s%s\n", c0, str, c1);
     fflush(stderr);
   }
 }
@@ -251,7 +295,11 @@ void Msg::Warning(const char *fmt, ...)
 #endif
 
   if(CTX::instance()->terminal){
-    fprintf(stderr, "Warning : %s\n", str);
+    const char *c0 = "", *c1 = "";
+    if(!streamIsFile(stderr) && streamIsVT100(stderr)){
+      c0 = "\33[35m"; c1 = "\33[0m";  // magenta
+    }
+    fprintf(stderr, "%sWarning : %s%s\n", c0, str, c1);
     fflush(stderr);
   }
 }
@@ -326,7 +374,11 @@ void Msg::Direct(int level, const char *fmt, ...)
 #endif
 
   if(CTX::instance()->terminal){
-    fprintf(stdout, "%s\n", str);
+    const char *c0 = "", *c1 = "";
+    if(!streamIsFile(stderr) && streamIsVT100(stderr)){
+      c0 = "\33[34m"; c1 = "\33[0m";  // blue
+    }
+    fprintf(stdout, "%s%s%s\n", c0, str, c1);
     fflush(stdout);
   }
 }
diff --git a/README.txt b/README.txt
index ba05bf288c48bf24241efb3d510cc4fd0f763ba5..4e458c43a43e3e19078a6f255cc90ba414ea0df7 100644
--- a/README.txt
+++ b/README.txt
@@ -1,63 +1,58 @@
-This is Gmsh, an automatic three-dimensional finite element mesh
-generator with built-in pre- and post-processing facilities.
+This is Gmsh, an automatic three-dimensional finite element mesh generator with
+built-in pre- and post-processing facilities.
 
-Gmsh is distributed under the terms of the GNU General Public License,
-Version 2 or later, with an exception to allow for easier linking with
-external libraries. See doc/LICENSE.txt and doc/CREDITS.txt for more
-information.
+Gmsh is distributed under the terms of the GNU General Public License, Version 2
+or later, with an exception to allow for easier linking with external
+libraries. See doc/LICENSE.txt and doc/CREDITS.txt for more information.
 
-See the doc/ and tutorial/ directories for documentation. The
-reference manual is located in doc/texinfo/. See the demos/ directory
-and the web site http://geuz.org/gmsh for additional examples.
+See the doc/ and tutorial/ directories for documentation. The reference manual
+is located in doc/texinfo/. See the demos/ directory and the web site
+http://geuz.org/gmsh for additional examples.
 
 Building Gmsh from its source code requires a C++ compiler and CMake
-(http://cmake.org).  Building the graphical user interface requires
-FLTK 1.1.7 or above (http://fltk.org), configured with OpenGL
-support. Building the 64 bit graphical version on MacOS X requires
-FLTK 1.3.
+(http://cmake.org).  Building the graphical user interface requires FLTK 1.1.7
+or above (http://fltk.org), configured with OpenGL support. Building the 64 bit
+graphical version on MacOS X requires FLTK 1.3.
 
 
 Build Gmsh using CMake's graphical user interface
 -------------------------------------------------
 
-* Launch CMake and fill-in the two top input fields (telling where the
-  Gmsh source directory is located and where you want the Gmsh binary
-  to be created).
+* Launch CMake and fill-in the two top input fields (telling where the Gmsh
+  source directory is located and where you want the Gmsh binary to be created).
 
-* Click on "Add entry" and define the variable CMAKE_PREFIX_PATH, of
-  type "PATH", pointing to the location(s) of any external package(s)
-  (FLTK, BLAS/LAPACK, etc.) installed in non-standard directories. 
+* Click on "Add entry" and define the variable CMAKE_PREFIX_PATH, of type
+  "PATH", pointing to the location(s) of any external package(s) (FLTK,
+  BLAS/LAPACK, etc.) installed in non-standard directories.
 
   (If you are using our pre-compiled "gmsh dependencies" package
-  (http://geuz.org/gmsh/bin/Windows/gmsh-dep-msvc2008-release.zip)
-  with Visual Studio on Windows simply point CMAKE_PREFIX_PATH to the
-  "gmsh-dep" directory.)
+  (http://geuz.org/gmsh/bin/Windows/gmsh-dep-msvc2008-release.zip) with Visual
+  Studio on Windows simply point CMAKE_PREFIX_PATH to the "gmsh-dep" directory.)
 
 * Click on "Configure" and choose your compiler (e.g. Visual Studio).
 
-* Optionally change some configuration options (re-run "Configure"
-  every time you change some options).
+* Optionally change some configuration options (re-run "Configure" every time
+  you change some options).
 
-* Once you are happy with all the configuration options, click on
-  "Generate".
+* Once you are happy with all the configuration options, click on "Generate".
 
 * Go to the build directory and build Gmsh using your chosen compiler.
 
   (With Visual Studio double-click on "gmsh.sln". If you are using our
-  pre-compiled "gmsh dependencies" package you must use the "Release"
-  or "RelWithDebInfo" build type.)
+  pre-compiled "gmsh dependencies" package you must use the "Release" or
+  "RelWithDebInfo" build type.)
 
 
 Build Gmsh from the command line
 --------------------------------
 
-* Create a build directory, for example as a subdirectory of Gmsh's
-  source directory:
+* Create a build directory, for example as a subdirectory of Gmsh's source
+  directory:
 
     mkdir build
 
-* Run cmake from within the build directory, pointing to Gmsh's
-  source directory:
+* Run cmake from within the build directory, pointing to Gmsh's source
+  directory:
 
     cd build
     cmake ..
@@ -67,18 +62,17 @@ Build Gmsh from the command line
     make
     make install
 
-* To change build options you can use "ccmake" instead of "cmake",
-  e.g.:
+* To change build options you can use "ccmake" instead of "cmake", e.g.:
 
     ccmake ..
 
-  or you can specify options directly on the command line. For
-  example, you can use
+  or you can specify options directly on the command line. For example, you can
+  use
 
     cmake -DCMAKE_PREFIX_PATH=/opt/local ..
 
-  to specify the location of external packages installed in
-  non-standard directories. You can use
+  to specify the location of external packages installed in non-standard
+  directories. You can use
 
     cmake -DCMAKE_INSTALL_PREFIX=/opt
 
@@ -88,17 +82,17 @@ Build Gmsh from the command line
 
   to build a version of Gmsh without the FLTK graphical interface.
 
-* You can keep multiple builds with different build options at the
-  same time. For example, you could configure a debug graphical build
-  in a "bin" subdirectory with
+* You can keep multiple builds with different build options at the same
+  time. For example, you could configure a debug graphical build in a "bin"
+  subdirectory with
 
     cd bin
     cmake -DCMAKE_BUILD_TYPE=Debug .. 
     make
     make install
 
-  and static and dynamic non-graphical release libraries in a "lib"
-  subdirectory with
+  and static and dynamic non-graphical release libraries in a "lib" subdirectory
+  with
 
     cd lib
     cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_FLTK=0 -DENABLE_OCC=0 ..
diff --git a/doc/WELCOME.txt b/doc/WELCOME.txt
index d9d0549e1fe913635e9cc841cc8a759449c11a2f..d0966232140c39f7c4520145762fc30653f32176 100644
--- a/doc/WELCOME.txt
+++ b/doc/WELCOME.txt
@@ -1,10 +1,9 @@
-This is Gmsh, an automatic three-dimensional finite element mesh
-generator with built-in pre- and post-processing facilities.
+This is Gmsh, an automatic three-dimensional finite element mesh generator with
+built-in pre- and post-processing facilities.
 
-Gmsh is distributed under the terms of the GNU General Public
-License. See the LICENSE.txt and CREDITS.txt files for more
-information.
+Gmsh is distributed under the terms of the GNU General Public License. See the
+LICENSE.txt and CREDITS.txt files for more information.
 
-The tutorial/ directory contains the examples from the tutorial
-chapter in the reference manual (http://geuz.org/gmsh/doc/texinfo/).
-The demos/ directory contains additional examples.
+The tutorial/ directory contains the examples from the tutorial chapter in the
+reference manual (http://geuz.org/gmsh/doc/texinfo/).  The demos/ directory
+contains additional examples.