Coloring console output in windows - haskell

I was trying to find if it is possible to colour console output in windows system. I found that Console - Ansi but i cant find any information about coloring output in windows prompt.
I woudl appreciate information about my problem.

It's been a while, but I think the correct usage is:
setRGB [SetColor Foreground Yellow, SetColor Background Red]
to set yellow writing on a red background. Also setTitle followed by a String sets the console window title.

It worked for me like this:
set the foregroundcolor to Yellow
setSGR [SetColor Foreground Vivid Yellow]
and then reset it to normal after putting your String on the screen
putStrLn "ayellowstring"
setSGR [Reset]
You need
import System.Console.ANSI
to do this

PowerShell and the console setting will be the solution.Console only have 16 colors,but you can config any 16 colors you like(i.e. you can make gray scale console)
this link explain how to

Related

Guake terminal displays incorrect colors (insufficient contrast)

I use two dropdown terminals in parallel: Yakuake and Guake.
When using Guake, the colors are way too dark, which makes much of the colored text unreadable because of insufficient contrast. The problem is most severe when displaying color #4 (dark blue) on black background (which is the default color ls displays directories with) or in Midnight Commander (default theme, dark blue background).
Yakuake displays all 16 colors correctly and the text is readable very well, the colored output of ls and Midnight Commander.
My OS is Linux 5.15.11-gentoo with plasma-5.88.0, gtk+-2.24.33 and gtk+-3.24.29. Here is my TERM setting in the environment:
TERM=xterm-256color
COLORTERM=yes
I tried all available Guake themes and all of them have horrible contrast. Either all colors are too dark, or the other way around - all of them are too bright. It seems Guake somehow compresses the color contrast.
I also tried defining custom colors, copying the color settings from Yakuake, but even though I set specific colors explicitly, the actually displayed colors were darker. I validated this with a color picker.
Changing the GTK Theme setting in Guake's preference tab General did not yield any success either.
The question is: Why does Guake alter the colors? Is there a way to turn this off and let it display the actual colors I specified? The problem must be with Guake or GTK because everything else is identical when using Yakuake (environment, Midnight Commander colors, ls colors, ...)
The following screenshots demonstrate my Guake Appearance settings:
And here is some Guake support information:
<details><summary>$ guake --support</summary>
Guake Version: 3.8.0
Vte Version: 0.64.2
Vte Runtime Version: 0.64.2
--------------------------------------------------
GTK+ Version: 3.24.29
GDK Backend: <GdkX11.X11Display
--------------------------------------------------
Desktop Session: /usr/share/xsessions/plasma
--------------------------------------------------
Display: :0
RGBA visual: True
Composited: True
Thanks a lot in advance.
It turns out ls renders directories as bold font with the expectation that the text will appear in bright color. As explained by Guake developers this is non-standard behavior used with old terminals that did not supported fonts. Guake follows the ANSI standard and renders the text correctly.
The solution is to tweak the ls colors accordingly.

How to adapt to Linux terminal back color in .NET 5/6?

We have a .NET 5 console application that runs on Windows/Linux/Mac.
Our console application relies on the classic fore color scheme to highlight info/warning/error in console with fore colors gray/yellow/red. However we cannot gather the terminal back color as explained in Console.BackgroundColor documentation:
Unix systems don't provide any general mechanism to fetch the current
console colors. Because of that, BackgroundColor returns
(ConsoleColor)-1 until it is set in explicit way (using the setter).
For now we force the console backcolor to be black but this doesn't render nicely when the terminal back color is white:
If we could guess the terminal back color we could adapt our forecolor to the terminal back color (like black fore color if the terminal back color is white and vice-versa). But from answers to this question How to determine a terminal's background color? it looks there is no standard way of getting background color that works on Mac and all Linux.
What is the common way to address this?
Ok we found a solution this way:
A colored message has white forecolor on a dark enough backcolor, so no matter the user backcolor, colored messages appear highlighted
Once we modified the Console.ForegroundColor and Console.BackgroundColor to show a colored message, the astute is to call Console.ResetColor() that sets back fore and back colors to their default values
This works no matter the terminal's default colors.
One point to note is that you shoudn't call Console.WriteLine(text) that provokes some back color problems on the remaining line characters. Instead call Console.Write(text) before Console.ResetColor() and then line feed is obtained with a call to Console.WriteLine().
System.Console.WriteLine("This is an info A");
System.Console.ForegroundColor = ConsoleColor.White;
System.Console.BackgroundColor = ConsoleColor.Red;
System.Console.Write("This is an error");
System.Console.ResetColor();
System.Console.WriteLine();
System.Console.WriteLine("This is an info B");
System.Console.ForegroundColor = ConsoleColor.White;
System.Console.BackgroundColor = ConsoleColor.DarkYellow;
System.Console.Write("This is a warning");
System.Console.ResetColor();
System.Console.WriteLine();
System.Console.WriteLine("This is an info C");
System.Console.ForegroundColor = ConsoleColor.White;
System.Console.BackgroundColor = ConsoleColor.Green;
System.Console.Write("This is a success");
System.Console.ResetColor();
System.Console.WriteLine();
System.Console.WriteLine("This is an info D");

Why does my text shows cyan background despite having a transparent background?

I'm a tester of Genexus and I'm working on a Linux while my programmer is working on a Windows.
I'm having a problem with a text because on my computer (Linux using Firefox/Chrome) I see the text with a Cyan background-color while my programmer working on Windows and Chrome he sees the background color as transparent.
He showed me the properties of the text and the background color is set to transparent.

How to make the input and output color different in Terminal?

In Pycharm-run, the input text color is always green and Italic while the output is always in plain text in white, which really helps me to distinguish the input from the output. How do I do that in Linux terminal or in VSCode?
I use Linux mint and i can easily change the color of font , color of palette, output color, size and all by opening the terminal -> Edit -> Preferences. It has all the options .I hope this helps.
open the bash terminal
go to .bashrc using vi or nano
at the end of the file add the PS1
PS1="\e[1;31m\u#\h \W$ \e[0;0m"
This code at the end of the rc file will make your prompt red and bold
There are many ways you can change by manipulating the characters in it.
Here is an useful link: https://phoenixnap.com/kb/change-bash-prompt-linux

Redhat Linux - change directory color

I am using Redhat Linux and the problem I am facing is that the "blue" colour of the directories is hardly visible on the black background. I found some posts on the web which asks to change some settings in the file /etc/profile.d/colorls.sh and /etc/profile.d/colorls.csh. However, this will change the colour settings for everyone who logs into the system. Could someone please let me know how I can change the colour settings that will affect only me?
To specify the colors of the output of ls, you need to set LS_COLORS. In your .zshrc, try adding:
LS_COLORS="$LS_COLORS:di=00;33"
34 is blue, 33 is ... yellowish. Change that number and find what you like.
Use dircolors to get a feel for what LS_COLORS should look like and add -p to see a color list.
Joachim's answer is good for fixing the specific issue of directories, but if any other utilities output using the "blue" color, you will find them just as unreadable.
Different terminal emulators have different settings for changing the colors; my terminal emulator of choice reads X resources to determine what colors to use:
URxvt.color0: #000000
URxvt.color1: #A80000
URxvt.color2: #00A800
URxvt.color3: #A8A800
URxvt.color4: #0000A8
URxvt.color5: #A800A8
URxvt.color6: #00A8A8
URxvt.color7: #A8A8A8
URxvt.color8: #000054
URxvt.color9: #FF0054
URxvt.color10: #00FF54
URxvt.color11: #FFFF54
URxvt.color12: #0000FF
URxvt.color13: #FF00FF
URxvt.color14: #00FFFF
URxvt.color15: #FFFFFF
color4 is the blue in question; I have mine set like this:
URxvt.background: #000000
URxvt.foreground: gray75
URxvt.color3: DarkGoldenrod
URxvt.color4: RoyalBlue
URxvt.color11: LightGoldenrod
URxvt.color12: LightSteelBlue
URxvt.color7: gray75
URxvt.colorBD: #ffffff
URxvt.colorUL: LightSlateGrey
URxvt.colorIT: SteelBlue
URxvt.cursorColor: grey90
URxvt.highlightColor: grey25
This gives a black background, not-too-bright foreground, and most other colors are reasonable enough. (I too found the default blue unreadable.) I put these into my ~/.Xresources file, and they take effect after log in or after merging this file with the X resources database: xrdb -merge ~/.Xresources.
Of course, different terminals are configured differently. Check your terminal's manpage for more details on changing the colors of the usual colors.
You can see what is done in the global file, and then add it to your private ~/.profile (or similar file.)
samolod solution is good.
In case of KDE konsole you go to
Settings -> Edit current profile -> Appearance -> Edit -> Color 5.
Then use graphical color chooser to make it brighter (I picked #5871FF).

Resources