Questions tagged [ansi-colors]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
23 views

How to convert ANSI color to RGB and in the opposite state (RGB -> ANSI)?

I could not find information about how I can translate ansi colors to RGB/HEX. If you know the answer to this question or are ready to share a link, I will be very glad I want to get the RGB color ...
0 votes
1 answer
394 views

Printing ANSI color codes in java works on VS Code terminal but not in CMD?

I wanted to Print Colored Text in Java Console. I have Ran the following code in VSCode and it Runs fine and its not working in CMD. The java Code: ` // Java Program to Print Colored Text in ...
  • 11
0 votes
1 answer
259 views

echo not printing \033 correctly in pipeline started by os.system()

In bash (as started by Python), I want to print this string \033[31m so that I can use a pipe | operator after it, followed by a command to copy that string to the clipboard. This means that in ...
  • 128
0 votes
0 answers
135 views

Convert text file with ansi colours to pdf

I have a plain text file containing ansi escape codes for colouring text. If it matters, I generated this file using the python package colorama. How can convert this file to pdf with colors properly ...
  • 7,908
0 votes
2 answers
341 views

Change colour of specific characters in string in C

Say I have some ASCII art in string presented as a variable as follows: char LOGO[3][40] = { " /$$ /$$ ", " | $$ |__/ &...
  • 39
2 votes
1 answer
195 views

How to wrap color coded text to fixed line length in terminal?

For text with color codes, how to wrap it to a fixed length in the terminal? Text without color codes wraps nicely with fold: echo -e "12345678901234567890" | fold -w 10 1234567890 ...
2 votes
2 answers
313 views

Is there a way to preserve ANSI control codes in PowerShell command output?

In PowerShell, is there a way to preserve the ANSI control codes used to convey color information to the console when assigning a program's output to a variable? For instance, I use Test Kitchen which ...
  • 18.7k
0 votes
0 answers
180 views

How to get ansi colors from Qemu serial in bash running on Windows

I'm using Windows 10 Terminal (v1.12.10982.0) Bash from Cmder (v4.4.23(1)-release) Quemu (v7.0.0-11902-g1d935f4a02-dirty) The terminal supports ansi colors (e.g., echo -e "\033[0;34mI'm blue\...
0 votes
2 answers
2k views

How do I get python to interpret the ANSI escape codes for colors in a string read from a text file

All the codes I've tried work in VS Code terminal and the Widows Terminal (Power Script and Command Window), so I'm pretty happy about that, however, when I read a string from a text file and I print ...
  • 21
0 votes
1 answer
307 views

How to use normal colors in vim on MacOS terminal

I have an issue with vim on MacOS terminal. This is a screenshot of my terminal colour palette: and here is an example of a file open in vim My .vimrc is the following: syntax on set noswapfile set ...
  • 189
0 votes
2 answers
2k views

How to use ANSI color codes to print colored text to bash terminal from a file?

I have a file (file.txt) like this: Yes Yes No No and I want to output this file to a bash terminal with "Yes" as green and "No" as red. I have written the following script: RED='\...
  • 11
0 votes
2 answers
1k views

How to get the RGB values of a 256-color palette terminal color

Thanks to ANSI escape codes, when you run: echo -e "\e[38;5;74mHi" This will display "Hi", colored with the palette color 74 (commonly a blue/cyan, but it may be another color, ...
  • 8,597
6 votes
1 answer
404 views

How to print a R dataframe with colors?

With the crayon package, one can create colored strings: library(crayon) dat <- data.frame(X=c(yellow("foobar"), green("baz")), Y = cyan("qux")) Here is the encoded ...
0 votes
1 answer
626 views

Can I change the text color through sprintf in C?

I'm new to C and I came across this code and it was confusing me: sprintf(banner1, "\e[37╔═╗\e[37┌─┐\e[37┌┐┌\e[37┌─┐\e[37┌─┐\e[37┌─┐\e[37┌─┐\e[37m\r\n"); sprintf(banner2, "\e[37╠═╝\e[37├...
  • 27
1 vote
0 answers
311 views

Live console output with colors on jenkins with pytest

How to see to console output in live on jenkins with pytest? Important note: I need also to see the colors with AnsiColor and I see them with this command: pytest [path_to_test] --capture tee-sys But ...
  • 35
0 votes
1 answer
180 views

Why is pytest outputting ANSI escape characters?

I am getting an AssertionError when running the pytest code below. For some reason the expected message is outputting with ansi escape codes instead of outputting the text with color. I am using a ...
1 vote
1 answer
56 views

Why SaltStack execution stack isn't well format?

Good morning guys, For an internal project I use SaltStack to install in instance of an application. But when I execute my state, at the end of execution, the output isn't well format. For exemple : ...
  • 330
3 votes
2 answers
3k views

Python colored text to the terminal [duplicate]

We can set color text or foreground color text in the terminal in Python. I have gone through this SO's answer. Some of the example color code is here class bcolors: HEADER = '\033[95m' OKBLUE ...
  • 2,897
4 votes
1 answer
247 views

How to color text more efficiently?

So I know how to color text, I am using a class to define colors and then using that in a print statements - class color: purple = '\033[95m' cyan = '\033[96m' darkcyan = '\033[36m' blue = '\033[...
0 votes
1 answer
69 views

How do I wrap Unicode text containing ANSI color codes at word boundaries?

How do I wrap Unicode text containing ANSI color codes at word boundaries? I know of grep -Eo ".{1,$w}" to wrap Unicode text, but it does not respect word boundaries and ANSI codes.
  • 3,142
2 votes
1 answer
1k views

Git Bash in Windows Terminal not rendering Picocli ANSI color codes

I have added Git Bash to Windows Terminal as explained in Adding Git-Bash to the new Windows Terminal. My profile looks as follows: { "guid": "{00000000-0000-0000-ba54-000000000002}&...
  • 135
0 votes
1 answer
557 views

Will os.system("color") in a script cause trouble if the program runs in Mac OS?

I have a set of text-analysis programs in Python. I want the menu and selected Terminal output to be in various colors. I have it working as desired by including os.system("color") at the ...
2 votes
1 answer
435 views

AWS CLI returns JSON with control codes making JQ fail

I've used jq many times to parse, pick values etc from JSON returned by AWS CLI, e.g. for ec2 describe-instances etc. Now I'm using the dockerized version of AWS CLI v2 to get a list of CloudWatch log ...
  • 8,171
1 vote
0 answers
104 views

How do I capture logs with colour formatters in python behave?

I would like to have coloured output in logging captured by python behave and print it in case of test failures. For example, this logging captured by pytest: While a similar test on behave produce ...
  • 1,840
0 votes
1 answer
884 views

How to grep with input ansi color encoding maintained?

The following grep does not maintain the input ANSI color encoding. Is there a way to maintain the original color encoding? $ builtin printf '%s\n' $'\e[33mx\e[0m' | grep $'\e\[33m' x
  • 11.4k
0 votes
2 answers
208 views

printf escape code not formatting in Bash script

I've recently started playing around with Bash, mostly using it to customize my .profile, and I've ran into an issue with the printf command. In my scripts folder, I have an associative array set up ...
  • 32
1 vote
1 answer
152 views

Where and How Bash convert strings to colors

I am working on Bash 5.0 from GNU repository. I wanted to find the place where Bash reads a string with ASCII colors and convert it to colors, like in the following case where it convert "Hello&...
  • 10.8k
0 votes
1 answer
542 views

Why colored text is not shown in terminal? Python [duplicate]

I'm trying to print some colored text, however every method I tried failed, the Interpreter just prints the color codes as well with the text, it does not change the color any ideas why? I am using ...
0 votes
3 answers
463 views

How to use System.out.format with colorized text

I want to colorize a formatted output. But the format of the colorized text is ignored: String leftAlignFormat = "| %-15s | %-15s |"; System.out.format(leftAlignFormat, "\033[38;5;16;48;...
  • 277
6 votes
1 answer
2k views

How to test if console supports ANSI color codes?

I use fmt based logger with optionally color prints - which relies on ANSI color commands. Unfortunately on Windows 10 it is disabled by default. I know how to enable it but I still want to find out ...
  • 4,088
2 votes
1 answer
856 views

How to enable ANSI colors with Log4j2 on Windows Terminal?

Unlike CMD and PowerShell, the new Windows Terminal supports ANSI colors out of the box. A quick test program can confirm that things are working: public class Color { public static void main(...
  • 578
2 votes
1 answer
126 views

Piping python script print out with sed (removing ansi colors) and writing it to a file

I'm trying to both see the colorful print out in my python script and writing it to a file without the ansi colors at the same time. This seems to working fine for me (only save it to a file): $...
  • 7,563
1 vote
1 answer
408 views

How can I get ANSI colour-codes to work in the Windows CMD?

How can I get ANSI escape codes to output coloured terminal outputs in the Windows CMD console using a C++ console application? This is what I've tried so far: #include <windows.h> #ifndef ...
0 votes
1 answer
461 views

aws sam cli-colored output in jenkins console

From version 0.33.1 onwards, aws-sam-cli supports colored output. I'm trying to run the sam deploy command from Jenkins pipeline and the output is not displaying in colored format. I've installed ...
  • 1,010
1 vote
0 answers
190 views

how to flatten control/escape characters for clean file redirection in BASH linux

I'm looking for something that can remove control characters from an echo output and convert it to a string without control characters, while still looking exactly the same as in a bash terminal. ...
  • 11
1 vote
1 answer
1k views

AnsiColor plugin within Jenkins Pipeline Shared Library - Usage Issue

I defined a quick logger in my pipeline to test the colored logs with AnsiColor plugin. It works like a charm. def logger(String str, String level) { if (level == "ALERT") { ansiColor('...
  • 1,287
0 votes
1 answer
717 views

ANSI colour text not displayed in pytest-html report

In pytest html report, the ANSI colour text is not displayed correctly. But in console, I can see the output with out any issue.Please see my conftest.py and let me know if I have to make any changes ...
  • 121
-1 votes
1 answer
316 views

How to use escape sequences [duplicate]

I am trying to get escape sequences to work in a Go application. Specifically the code to move the cursor. fmt.Printf("\033[3;5H") What should I be printing / writing to in order to make this work? Or ...
6 votes
0 answers
400 views

Display ANSI colours in a Slack Snippet

I am using Slack and Hubot to run a few commands on our servers, the stdout and stderr of these commands is uploaded to a channel as a snippet. Some of these commands return colour outputs and are ...
  • 1,239
0 votes
2 answers
4k views

How to get color in Lua console/terminal

Is there a simple way to have the generic Lua console/terminal in windows display colors? I am basically running the lua53.exe terminal in windows and want to display things with colors. Mainly in ...
  • 1
3 votes
1 answer
4k views

Print colored raw output with jq on terminal

I'm trying to print a report on the terminal. The report is JSON and I print it on the terminal as a raw jq output. I'm trying to color the output for few values something on the lines of echo -e "\...
  • 315
3 votes
2 answers
347 views

Colored text in command prompt after "cls" but not before "cls"

I have a python program where I am trying to print "Hello" in colored text using ANSI codes in command prompt. When I print in normally, it is not working, it just prints ? and text, but when I print ...
10 votes
2 answers
9k views

Print bold or colored text from Makefile rule

I'm trying to print bold text from the following Makefile : printf-bold-1: @printf "normal text - \e[1mbold text\e[0m" But, escape sequences are printed as-is, so when running make printf-bold-1,...
  • 9,176
0 votes
1 answer
112 views

How to count symbol instead of string length with Fish?

In a discussion on a pull request for pure theme for fish we are wondering how to count the number of symbols instead of the string length. Doing such will allow to refactor our code in a more ...
0 votes
1 answer
1k views

Bash: ansi color when reading input from user [duplicate]

When using read command to get user input like the following read -p "[WARN] Text.. [Y/N]" choice Is it possible to assign an ANSI color to the warning text, like in echo command? WARN='\033[0;33m' ...
  • 3,665
2 votes
1 answer
224 views

How do I escape color codes in Bash?

I have some color codes in my ~/.bashrc: export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold export LESS_TERMCAP_me=$'\E[0m' # ...
1 vote
2 answers
777 views

How to remove ansi code from output piped to VSCode?

As of November 2017 VSCode allow to pipe output directly to VSCode. I did tried with a few command until I got a bunch of ANSI codes which I'm not interested. I'm running something like yarn info ...
14 votes
2 answers
9k views

output of [31m text instead of color

I am trying to print coloured text with colorama but when I compile an exe and run following... from colorama import Fore, Back, Style print(Fore.RED + 'text') print(Back.GREEN + 'and with a green ...
user avatar
1 vote
2 answers
518 views

Is it possible to print from Python using non-ANSI colors?

I'm trying to print log/print text to the terminal with custom colors using Python. I looked around, but couldn't find anything other than ANSI colors. Do I have to use ANSI colors, or am I able to ...
  • 1,243
0 votes
2 answers
690 views

Difference between ANSI color?

I was searching about changing output color for console in NetBeans and found this post. I tried the first answer and worked perfectly for changing colors. I tried the fifth answer and... worked too. ...