ansi-colors

how to get current terminal color pair in bash

匆匆过客 提交于 2019-12-03 16:12:57
问题 I would like to query and store the current terminal color pair in BASH e.g.: #!/bin/bash #some ANSI colour escape sequences red="\033[0;31m" grn="\033[0;32m" blu="\033[0;34m" def="\033[0;00m" # default echo -e "Change to ${red} red to ${def} default to ${blu} blue." # now store the current color (which happens to be blue) e.g.: cur=???? echo -e "Change to ${grn} green and back to what I had before ${cur}" echo -e "This would be in blue if variable cur contained e.g.: 0;34m." echo -e "Back to

how to get current terminal color pair in bash

北城余情 提交于 2019-12-03 10:54:15
I would like to query and store the current terminal color pair in BASH e.g.: #!/bin/bash #some ANSI colour escape sequences red="\033[0;31m" grn="\033[0;32m" blu="\033[0;34m" def="\033[0;00m" # default echo -e "Change to ${red} red to ${def} default to ${blu} blue." # now store the current color (which happens to be blue) e.g.: cur=???? echo -e "Change to ${grn} green and back to what I had before ${cur}" echo -e "This would be in blue if variable cur contained e.g.: 0;34m." echo -e "Back to default${def}" exit 0 The answer that eludes me is how to capture the current color cur=???? The

RGB values of the colors in the Ansi extended colors index (17-255)

一曲冷凌霜 提交于 2019-12-03 03:17:53
问题 My question is in general shell scripting with ansi colors but for reference I am using an Apple Mac OS X 10.9 Mavericks. I use "iTerm" terminal app as my default terminal but also checked with the built in "terminal" app as well. I use ZSH (5.0.7) as my default shell but also checked in BASH (3.2.51). I have been trying to find out if there is a list of the RGB values for the 256 color indexed extended fore/background Ansi escape codes that are available using esc[38;5;xm and esc[48;5;xm

RGB values of the colors in the Ansi extended colors index (17-255)

爱⌒轻易说出口 提交于 2019-12-02 16:48:15
My question is in general shell scripting with ansi colors but for reference I am using an Apple Mac OS X 10.9 Mavericks. I use "iTerm" terminal app as my default terminal but also checked with the built in "terminal" app as well. I use ZSH (5.0.7) as my default shell but also checked in BASH (3.2.51). I have been trying to find out if there is a list of the RGB values for the 256 color indexed extended fore/background Ansi escape codes that are available using esc[38;5;xm and esc[48;5;xm where x is a number from 0 to 255. I have found some scripts that print out the colors as blocks (using

Can't enable 256 colors in ConEmu

烂漫一生 提交于 2019-12-02 16:19:21
I'm trying to get 256 colors in the fantastic ConEmu-Maximus5 console. Update: Now it only shows 8 colors. I know because '$tput colors' output is '8' I have followed the instructions and activated: TrueMod (24-bit color) support Inject ConEmuHk ANSI x3.64 / xterm 256 colors I don't understand what to do with ' check off whether the buffer / slide. ' I'm in windows 7. I start ConEmu with a custom direct link, so it loads cygwin bash file. "C:\Program Files\ConEmu\ConEmu64.exe" /cmd ""C:\cygwin\bin\bash.exe" --login -i" In my bashrc profile I have -> export TERM=cygwin This is my custom command

Is there an easy way to COLOR-CODE the compiler outputs?

冷暖自知 提交于 2019-12-02 15:08:48
gcc (or other compilers) often generate huge text output and it's very difficult to see where the error is or miss warnings. I've done some search but havn't found a clean simple solution to color code the compiler output (so for instance warnings are yellow, errors are red, etc...) here's an alternative if you are looking for something very simple: #!/bin/bash -e make ${@} 2>&1 | perl -wln -M'Term::ANSIColor' -e ' m/Building|gcc|g++|\bCC\b|\bcc\b/ and print "\e[1;32m", "$_", "\e[0m" or m/Error/i and print "\e[1;91m", "$_", "\e[0m" or m/Warning/i and print "\e[1;93m", "$_", "\e[0m" or m

How to correctly enable ANSI colors in ConEmu + Git Bash?

六月ゝ 毕业季﹏ 提交于 2019-11-30 15:02:44
问题 I'm using Git Bash with ConEmu to make it look cool. However, upon installing Composer the colors seem to be escaped: So Git Bash does not support all the colors. Checking the AnsiColors256.ans file: After lots of Googling, I still haven't found any solution. I don't want to use Ansicon or other console emulator, ConEmu is fine for me. My settings: Inject ConEmuHk enabled Ansi X3.64 / xterm 256 enabled Windows 7 x64 Git Bash 1.9.5 ConEmu 141208 How do I enable all the colors? This is annoying

Getting correct string length in Python for strings with ANSI color codes

烂漫一生 提交于 2019-11-29 03:09:05
I've got some Python code that will automatically print a set of data in a nice column format, including putting in the appropriate ASCII escape sequences to color various pieces of the data for readability. I eventually end up with each line being represented as a list, with each item being a column that is space-padded so that the same columns on each line are always the same length. Unfortunately when I actually go to print this, not all the columns line up. I suspect this is to do with the ASCII escape sequences - because the len function doesn't seem to recognize these: >>> a = '\x1b[1m0

Reading the RGB values of the console color palette

烂漫一生 提交于 2019-11-28 08:41:15
问题 Meat In C or C++ is there any way to read the color palette RGB values directly? Especially interesting is the extended color space used by xterm (and others) to define up to 256 terminal colors. Potatoes The case in point is that I want to define my own colors (using ANSI escape sequences, like \e]4;3;rgb:cc/78/33\e\\ , or directly in c) but I need to save the users colors before I redefine them (in the unlikely event that they have already redefined their colors) so that I can restore them

Getting correct string length in Python for strings with ANSI color codes

一个人想着一个人 提交于 2019-11-27 17:25:08
问题 I've got some Python code that will automatically print a set of data in a nice column format, including putting in the appropriate ASCII escape sequences to color various pieces of the data for readability. I eventually end up with each line being represented as a list, with each item being a column that is space-padded so that the same columns on each line are always the same length. Unfortunately when I actually go to print this, not all the columns line up. I suspect this is to do with