terminal-color

Preserve colored output using php's popen

醉酒当歌 提交于 2019-12-24 17:15:24
问题 When using popen in php, is there a way to preserve the colored output a program might generate? Is there maybe a way I can tell the shell to print all color escape sequences, instead of resolving them? 回答1: That depends on the program you are calling. Usually, if a program supports coloured output, it would ask the OS, "am I running on a terminal?" If yes, then it outputs colour codes. If not, it won't. If you run that program through popen() , then the OS would say "no, you're not running

Coloring compiler diagnostics with SCons

依然范特西╮ 提交于 2019-12-22 18:27:26
问题 I am currently using the colorama package to color messages generated by my build scripts. I have also used scolorizer, which replaces the build commands with custom, colored messages using strfunction() in SCons. This sure makes build output less verbose and warnings easier to spot. However, I often prefer to see the full command lines when building. Is there a mechanism in SCons to capture compiler output, giving the opportunity to inject some terminal colors before printing it out? 回答1:

Coloring compiler diagnostics with SCons

喜欢而已 提交于 2019-12-22 18:27:15
问题 I am currently using the colorama package to color messages generated by my build scripts. I have also used scolorizer, which replaces the build commands with custom, colored messages using strfunction() in SCons. This sure makes build output less verbose and warnings easier to spot. However, I often prefer to see the full command lines when building. Is there a mechanism in SCons to capture compiler output, giving the opportunity to inject some terminal colors before printing it out? 回答1:

Coloring compiler diagnostics with SCons

≯℡__Kan透↙ 提交于 2019-12-06 13:34:53
I am currently using the colorama package to color messages generated by my build scripts. I have also used scolorizer , which replaces the build commands with custom, colored messages using strfunction() in SCons. This sure makes build output less verbose and warnings easier to spot. However, I often prefer to see the full command lines when building. Is there a mechanism in SCons to capture compiler output, giving the opportunity to inject some terminal colors before printing it out? You can do this by setting CC and CXX in the environment to a suitable wrapper around your compiler, for

Converting ANSI escape sequences to HTML using PHP

我是研究僧i 提交于 2019-12-05 23:57:53
问题 This is a similar question to this one. I would like to convert ANSI escape sequences, especially for color, into HTML. However, I would like to accomplish this using PHP. Are there any libraries or example code out there that do this? If not, anything that can get me part way to a custom solution? 回答1: I don't know of any such library in PHP. But if you have a consistent input with limited colors, you can accomplish it using a simple str_replace() : $dictionary = array( 'ESC[01;34' => '<span

Converting ANSI escape sequences to HTML using PHP

不打扰是莪最后的温柔 提交于 2019-12-04 05:12:11
This is a similar question to this one . I would like to convert ANSI escape sequences, especially for color, into HTML. However, I would like to accomplish this using PHP. Are there any libraries or example code out there that do this? If not, anything that can get me part way to a custom solution? I don't know of any such library in PHP. But if you have a consistent input with limited colors, you can accomplish it using a simple str_replace() : $dictionary = array( 'ESC[01;34' => '<span style="color:blue">', 'ESC[01;31' => '<span style="color:red">', 'ESC[00m' => '</span>' , ); $htmlString =

A library to convert ANSI escapes (terminal formatting/color codes) to HTML [closed]

血红的双手。 提交于 2019-11-26 12:35:14
问题 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;34mcodeESC[00m ESC[01;31mdropbox-lnx.x86-0.6.404.tar.gzESC[00m ESC[00mfooESC[00m Into this: <span style=\"color:blue\">bin</span> <span style=\"color:blue\">code</span> <span style=\"color:red\">dropbox-lnx.x86-0.6.404.tar.gz</span> foo Converting breaks into <br/> isn\'t necessary, it\'s just the escape

How to change the output color of echo in Linux

不想你离开。 提交于 2019-11-25 23:19:09
问题 I am trying to print a text in the terminal using echo command. I want to print the text in a red color. How can I do that? 回答1: You can use these ANSI escape codes: Black 0;30 Dark Gray 1;30 Red 0;31 Light Red 1;31 Green 0;32 Light Green 1;32 Brown/Orange 0;33 Yellow 1;33 Blue 0;34 Light Blue 1;34 Purple 0;35 Light Purple 1;35 Cyan 0;36 Light Cyan 1;36 Light Gray 0;37 White 1;37 And then use them like this in your script: # .---------- constant part! # vvvv vvvv-- the code from above RED='