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.

To encode this formatting information, it embeds certain sequences of bytes into the text, which have to be interpreted specially, not as codes of characters. Although hardware text terminals have become increasingly rare in the 21st century, the relevance of this standard persists because most terminal emulators interpret at least some of the ANSI escape sequences in the output text. One notable exception is the win32 console component of Microsoft Windows.

655 questions
41
votes
9 answers

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 have the color commands escaping correctly. However…
Rob
  • 3,687
  • 2
  • 32
  • 40
39
votes
11 answers

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 + "" + end But if I run it in Windows it doesn't work, how can I make the ANSI escape codes work also on Windows?
Eduard Florinescu
  • 16,747
  • 28
  • 113
  • 179
38
votes
5 answers

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 mode or any other mode. I know the solution has…
Son of the Wai-Pan
  • 12,371
  • 16
  • 46
  • 55
36
votes
7 answers

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 position echo -en '\033[6n' # Read it to a variable read…
nicoulaj
  • 3,463
  • 4
  • 27
  • 32
32
votes
6 answers

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?,…
Gajus
  • 69,002
  • 70
  • 275
  • 438
31
votes
3 answers

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, but it's not highlighted. Doing the same thing…
simont
  • 68,704
  • 18
  • 117
  • 136
29
votes
11 answers

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" and it returns the ANSI charaters.... esc[31mMy Text…
Mike
  • 4,099
  • 17
  • 61
  • 83
29
votes
7 answers

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…
27
votes
6 answers

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 do now is just echo a new line, and that's not…
Matt
  • 2,790
  • 6
  • 24
  • 34
27
votes
1 answer

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 changing text color. For example: echo -e…
Mark G.
  • 2,849
  • 2
  • 15
  • 15
22
votes
2 answers

How to print a string literally in Python

this is probably really simple but I can't find it. 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…
Ross W
  • 1,300
  • 3
  • 14
  • 24
21
votes
1 answer

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 pretty printing a binary tree and I found a way to…
Redacted
  • 613
  • 6
  • 23
21
votes
1 answer

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 ^[[1mCREATE TABLE "schema_migrations" ("version"…
A.D.
  • 4,487
  • 3
  • 38
  • 50
19
votes
2 answers

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 yellow for the same character :)
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
19
votes
1 answer

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 is what I expect. However, If I recall a command…
Xaq
  • 558
  • 1
  • 4
  • 13
1
2
3
43 44