Questions tagged [ansi-escape]
ANSI escape code (or escape sequences) is the method of in-band signaling to control formatting, color, and other output options on video text terminals.
674
questions
991
votes
40
answers
628k
views
How to change node.js's console font color?
I had to change the console background color to white because of eye problems, but the font is gray colored and it makes the messages unreadable. How can I change it?
669
votes
13
answers
694k
views
What are carriage return, linefeed, and form feed?
What is the meaning of the following control characters:
Carriage return
Line feed
Form feed
506
votes
8
answers
500k
views
List of ANSI color escape sequences
On most terminals it is possible to colorize output using the \033 ANSI escape sequence.
I'm looking for a list of all supported colors and options (like bright and blinking).
As there are probably ...
247
votes
22
answers
188k
views
Removing colors from output
I have some script that produces output with colors and I need to remove the ANSI codes.
#!/bin/bash
exec > >(tee log) # redirect the output to a file but keep it on stdout
exec 2>&1
...
142
votes
10
answers
121k
views
How can I remove the ANSI escape sequences from a string in python
Here is a snippet that includes my string.
'ls\r\n\x1b[00m\x1b[01;31mexamplefile.zip\x1b[00m\r\n\x1b[01;31m'
The string was returned from an SSH command that I executed. I can't use the string in its ...
97
votes
3
answers
37k
views
A library to convert ANSI escapes (terminal formatting/color codes) to HTML [closed]
I'm looking for a code library that converts ANSI escape sequences into HTML color, via plain tags or CSS. For example, something that would convert this:
ESC[00mESC[01;34mbinESC[00m
ESC[01;...
95
votes
14
answers
101k
views
How to make win32 console recognize ANSI/VT100 escape sequences in `c`?
I'm building a lightweight version of the ncurses library. So far, it works pretty well with VT100-compatible terminals, but win32 console fails to recognise the \033 code as the beginning of an ...
83
votes
6
answers
46k
views
An Eclipse console view that respects ANSI color codes?
The output from ScalaTest is colored to distinguish different states, but these end up as control codes and
[34m Annoying garbage
Is there any way to convince the Eclipse console to either respect ...
57
votes
6
answers
50k
views
ANSI Color Specific RGB Sequence Bash
I know that in bash terminals a reliable way to change color is using ANSI escape sequences. For example:
echo -e "\033[0;31mbrown text\033[0;00m"
should output
brown text (in brown)
Is there a ...
54
votes
6
answers
9k
views
ANSI Coloring in Compilation Mode
Have anyone added support for ansi-color in compilation-mode Emacs? If so what property/attribute does the color-writing program have to check for in order to make sure its active terminal supports ...
54
votes
3
answers
32k
views
Remove all ANSI colors/styles from strings
I use a library that adds ANSI colors / styles to strings. For example:
> "Hello World".rgb(255, 255, 255)
'\u001b[38;5;231mHello World\u001b[0m'
> "Hello World".rgb(255, 255, 255).bold()
'\...
53
votes
4
answers
30k
views
ANSI Color Codes in VIM
I have a script that generates a log file with ANSI color codes in them like so:
[2012-05-14 18:00:02] ^[[0mINF: -- Starting update script --^[[0m
[2012-05-14 18:00:29] ^[[91mERR: Improper date, ...
50
votes
4
answers
33k
views
Colored text output in PowerShell console using ANSI / VT100 codes
I wrote a program which prints a string, which contains ANSI escape sequences to make the text colored. But it doesn't work as expected in the default Windows 10 console, as you can see in the ...
47
votes
11
answers
43k
views
Text editor/viewer with ANSI codes rendering support for Windows [closed]
I need some tool to display text containing ANSI codes correctly on Windows. No full support needed, but at least coloring/bold is a must.
Reason: My logger/debug module produce nicely rendered rich ...
44
votes
3
answers
16k
views
How to detect if the console does support ANSI escape codes in Python?
In order to detect if console, correctly sys.stderr or sys.stdout, I was doing the following test:
if hasattr(sys.stderr, "isatty") and sys.stderr.isatty():
if platform.system()=='Windows':
...
41
votes
11
answers
67k
views
Python: How can I make the ANSI escape codes to work also in Windows?
If I run this in python under linux it works:
start = "\033[1;31m"
end = "\033[0;0m"
print "File is: " + start + "<placeholder>" + end
But if I run it in Windows it doesn't work, how can I ...
41
votes
9
answers
32k
views
Shell Prompt Line Wrapping Issue
I've done something to break my Bash Shell Prompt in OS X (10.5.7) Terminal.
This is the PS1 that I had configured:
PS1='\[\e[1;32m\]\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]\$ '
As far as I can tell I ...
39
votes
5
answers
15k
views
How do I display ANSI color codes in emacs for any mode?
I have a log file that uses ANSI escape color codes to format the text. The mode is fundamental. There are other answered questions that address this issue but I'm not sure how to apply it to this ...
36
votes
7
answers
45k
views
How to get the cursor position in bash?
In a bash script, I want to get the cursor column in a variable. It looks like using the ANSI escape code {ESC}[6n is the only way to get it, for example the following way:
# Query the cursor ...
34
votes
7
answers
27k
views
Is there a way to erase the last line of output?
A very simple program that prints 3 lines of output:
console.log('a');
console.log('b');
console.log('c');
Is there a way from program to delete the last line after it has been printed?, i.e.
console....
31
votes
3
answers
7k
views
tmux man-page search highlighting
When I search in, for example, man ls while in a tmux session, the search strings don't appear highlighted - the page jumps down so that the search string is on the top line of the buffer, as expected,...
30
votes
11
answers
59k
views
Colorama for Python, Not returning colored print lines on Windows
I've installed colorama for python. I've imported the module as follows:
import colorama
from colorama import init
init()
from colorama import Fore, Back, Style
print Fore.RED + "My Text is Red"
...
29
votes
7
answers
21k
views
Color ouput with Swift command line tool
I'm writing a command line tool with Swift and I'm having trouble displaying colors in my shell. I'm using the following code:
println("\033[31;32mhey\033[39;39m")
or even
NSFileHandle....
29
votes
6
answers
27k
views
bash script, erase previous line?
In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a bash script? All I can ...
28
votes
1
answer
13k
views
Can Terminal.app be made to respect ANSI escape codes?
I notice that with the TERM environment variable set to either xterm or xterm-256color that Mac OS X’s Terminal.app utility respects most ANSI escape codes, as least when those escape codes pertain to ...
24
votes
2
answers
28k
views
How to print a string literally in Python
I need to print what a string in Python contains. I'm collecting data from a serial port and I need to know if it is sending CR or CRLF + other control codes that are not ASCII.
As an example say I ...
23
votes
1
answer
5k
views
How to preserve colors in logs with Multitail?
Output of tail logs/development.log in XFCE Terminal:
multitail log/development.log
Rails adds escape codes to log files automatically. See development.log file:
^[[1m^[[36m (84.1ms)^[[0m ^[[...
21
votes
1
answer
3k
views
Printing up a line in java console (reverse of '\n')
Foreword
I've seen some questions related to this in other languages and done quite some research on this. First, before we begin going down the rabbit hole, I must describe why I'm doing this. I'm ...
19
votes
1
answer
2k
views
Adding ANSI color escape sequences to a bash prompt results in bad cursor position when recalling/editing commands
If I set my command prompt like:
export PS1='\033[0;33m[\u@\h \w]\$ \033[00m'
The color of the prompt will be yellow and everything after the '$' character will
be the default terminal color. This ...
19
votes
2
answers
21k
views
Is there a way to create an Orange color from ANSI escape characters?
I am looking for a control code to create orange text in a terminal using ANSI or some other standard, is this possible? I only see yellow and red available, and I don't think you can mix red and ...
18
votes
3
answers
14k
views
Python module to enable ANSI colors for stdout on Windows?
I am looking for a Python module that would add ANSI support under Windows.
This means that after importing the module, if you output ANSI escaped strings, they will appear accordingly.
18
votes
4
answers
5k
views
Reading the Device Status Report ANSI escape sequence reply
I'm trying to retrieve the coordinates of cursor in a VT100 terminal using the following code:
void getCursor(int* x, int* y) {
printf("\033[6n");
scanf("\033[%d;%dR", x, y);
}
I'm using the ...
16
votes
6
answers
27k
views
adding text decorations to console output
I have a c# .net 3.5 application that writes text to the console using a StreamWriter. Is there a way I can add text decorations like underline and strikethrough to the text that is printed to the ...
16
votes
1
answer
7k
views
How do I determine size of ANSI terminal?
Standard input and output are connected to a terminal that implements ANSI escape sequences, but is of unknown dimensions.
I need to know how big the terminal so to facilitate drawing a full-screen ...
16
votes
1
answer
6k
views
Save and restore terminal content
I am writing automation scripts (perl/bash). Many of them benefit from some basic terminal GUI. I figured I'd use standard ANSI sequences for basic drawing. Before drawing in terminal I do clear but ...
14
votes
6
answers
13k
views
Is it possible to display text in a console with a strike-through effect?
I have already looked into ANSI escape codes, but it looks like only underlining is supported.
Do I miss something or is there another option?
If it is not possible, is there something equivalent in ...
14
votes
1
answer
39k
views
ANSI questions: "\x1B[?25h" and "\x1BE"
What does "\x1B[?25h" do?
How is "\x1BE" different from "\n"? According to http://ascii-table.com/ansi-escape-sequences-vt-100.php it "moves to next line"? ...
13
votes
4
answers
8k
views
Bash printing color codes literally and not in actual color
For some reason my shell script stopped printing my menu in color and is actually printing the literal color code instead. Did I somehow escape the color coding?
Script
#!/bin/bash
function ...
13
votes
4
answers
16k
views
ANSI-Coloring Console Output with .NET
I try to generate colored console output using ANSI escape codes with the following minimal C# program:
using System;
// test.cs
class foo {
static void Main(string[] args) {
Console....
13
votes
3
answers
5k
views
Removing color decorations from strings before writing them to logfile
I use the ruby logger like this:
$logger = Logger.new MultiIO.new($stdout, log_file)
Where the MultiIO is a class I got from this answer. This works great, mostly, but I am using 'colored' rubygem ...
13
votes
1
answer
9k
views
Parse ANSI escape code colors in the browser?
I have a source that has ANSI escape code color attached to the strings it spits out. These strings are being sent to the browser. I want to parse these ANSI escape codes with javascript in the ...
12
votes
10
answers
54k
views
How can I use ANSI Escape Codes for outputting colored text in C and C++?
I read about ANSI-C escape codes here. Tried to use it in C/C++ printf/std::cout to colorize the text outputted to console, but without success.
My attempt:
#include <iostream>
#include <...
12
votes
3
answers
7k
views
How can I see the colored log using tail or less?
Reading a Rails log with vim, we can see a colored log.
But when we use tail -f or less to watch the log, it isn't colorized anymore. Is there any way to see the colored log with tail or less or ...
12
votes
2
answers
14k
views
How do I apply formatting like italic or bold to text using ANSI escaping sequences in a console?
How do I format text with ANSI escaping?
Like make things italic or bold and maybe strikethrough and super script.
12
votes
2
answers
6k
views
bash-program "watch" and ANSI escape sequences in the output [duplicate]
Possible Duplicate:
Colors with unix command “watch”?
In one of my programs, I want to use colored text as output, so I am using ANSI escape sequences for that, e.g. like this:
echo -e '\033[...
12
votes
5
answers
4k
views
256 color terminal library for Ruby?
Is there a gem like 'Term::ANSIColor' which works with 256 color terminals? The perl script 256colors2.pl works great in my terminal, and I'd like to use some of these colors in my ruby scripts ...
12
votes
2
answers
5k
views
Check if console supports ANSI escape codes in Java
I'm building a program in Java that uses menus with different colors using ANSI escape codes. Something like
System.out.println("\u001B[36m"+"Menu option"+"\u001B[0m");
The problem is that i want to ...
11
votes
6
answers
13k
views
Filtering out ANSI escape sequences [duplicate]
I have a python script that's trying to interpret a trace of data written to and read from stdout and stdin, respectively. The problem is that this data is riddled with ANSI escapes I don't care ...
11
votes
3
answers
130k
views
Print in bold on a terminal
How can I print output in bold using printf? "[1m testing bold" does not do anything.
String format = "%-20s %-15s %-20s %-15s %-10s";
System.out.printf(format, "Name", &...
11
votes
2
answers
23k
views
What does printf("\033[H\033[J") do in C? [duplicate]
I have gone through the below strange sequence of characters in some random website. When compiled and executed, this sequence cleared all previous content in terminal.
Does this clear the stdout ...