# Set console output color

**URL:** <https://swi-prolog.discourse.group/t/set-console-output-color/693>\
**Category:** Help!\
**Created:** [May 21, 2019, 5:23pm UTC](https://swi-prolog.discourse.group/t/set-console-output-color/693 "2019-05-21T17:23:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![abaljeu](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/abaljeu/32/136_2.png) [@abaljeu](https://swi-prolog.discourse.group/u/abaljeu)\
**Post date:** [May 21, 2019, 5:23pm UTC](https://swi-prolog.discourse.group/t/set-console-output-color/693/1 "2019-05-21T17:23:35Z")

</div>

I have

> “C:\Program Files\swipl\bin\swipl.exe” --goal=run\_server -o …....\build\server\startserv.exe -c load2.pl

Works great but the warnings come in red (on black) which is barely readable. How can I change this?

Doc search points me to this wiki page:  
[http://www.swi-prolog.org/FAQ/ColorConsole.txt](http://www.swi-prolog.org/FAQ/ColorConsole.txt)

I do not want to disable color. I don’t know what else I can try.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [May 21, 2019, 7:00pm UTC](https://swi-prolog.discourse.group/t/set-console-output-color/693/4 "2019-05-21T19:00:56Z")

</div>

Made some progress but not satisfied with it because it is not done from the top level.

Create a Prolog source code file, e.g. `message_property_test.pl`

```prolog
:- multifile
    user:message_property/2.

user:message_property(warning, color(fg(blue))).

test :-
 print_message(warning,'here').

```

Start top level

```prolog
Welcome to SWI-Prolog (threaded, 64 bits, version 8.0.0)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- 

```

Consult file and run test.

```prolog
?- consult('D:/Cellular Information/Source Code/Prolog/message_property_test.pl').
true.

?- test.
Warning: Unknown message: here
true.

?- 

```

It is really blue on my screen.

![Capture](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/1X/c1ac66b78ba64d855540eba36393ae8ecdb72972.png)

Hope that helps.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [May 21, 2019, 7:09pm UTC](https://swi-prolog.discourse.group/t/set-console-output-color/693/5 "2019-05-21T19:09:44Z")

</div>

One upon a time terminals were black with green characters. Then they got mostly white as this was supposed to be easier to read, something to which I fully agree. Now they seem to turn black again. I guess that is called innovation 🙂

Anyway, SWI-Prolog’s color palettes are designed for light backgrounds. The ones for PceEmacs are still fairly easy to modify AFAIK, but the ones for the terminal are hard coded and can only be disabled. What should happen is that the code should use symbolic names and an additional table should translate this to physical colors. As @EricGT points out this is already the case for print\_message/2 based on the _level_ argument (thanks, forgot about that). Still, boot/messages.pl uses direct ansi color names for e.g., **false** , etc.

That all is not that hard. There is one harder problem: find the current foreground and (notably) background color of the console. There is an ansi sequence to ask the terminal, but then you have to be aware that the reply may appear just about anywhere in the input due to delays and filled buffers.

If someone wants to sort it out, I’m more than happy to review and merge. A first attempt could or course demand the user to select the color theme in swipl.ini/.swiplrc

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [May 21, 2019, 7:13pm UTC](https://swi-prolog.discourse.group/t/set-console-output-color/693/6 "2019-05-21T19:13:51Z")

</div>

What is the value of the environment variable `TERM`?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [May 21, 2019, 7:16pm UTC](https://swi-prolog.discourse.group/t/set-console-output-color/693/7 "2019-05-21T19:16:45Z")

</div>

In general not of much use. @abaljeu is (I guess) the Windows console. I run `terminator`, on Ubuntu which tells me

```prolog
COLORTERM=truecolor
TERM=xterm-256color

```

That doesn’t change if I change the fore or background color.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [May 21, 2019, 8:42pm UTC](https://swi-prolog.discourse.group/t/set-console-output-color/693/8 "2019-05-21T20:42:23Z")

</div>

Does `TERM=xrvt` help? (I needed to do this to make Ubuntu-under-Windows usable, due to a bug that Microsoft has yet to fix)

---

<div class="post-metadata">

**Author:** ![abaljeu](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/abaljeu/32/136_2.png) [@abaljeu](https://swi-prolog.discourse.group/u/abaljeu)\
**Post date:** [May 22, 2019, 3:36pm UTC](https://swi-prolog.discourse.group/t/set-console-output-color/693/9 "2019-05-22T15:36:23Z")

</div>

> [@jan](#):
>
> One upon a time terminals were black with green characters. Then they got mostly white as this was supposed to be easier to read, something to which I fully agree. Now they seem to turn black again. I guess that is called innovation 🙂

Ah so I tried that, white on black. Works great. Until the next line of the script runs Visual Studio build, which dumps warnings in Yellow.

For what it’s worth, there is NO option to configure this in MSBuild, but Powershell has an ability to piping the output and recolor the text, so my problem is resolved.
