The ANSI/VT100 terminals and terminal emulators are not just able to display black and white text ;
they can display colors and formatted texts thanks to escape sequences. Those sequences are composed of
the Escape character (often represented by “^[
” or “<Esc>
”) followed by some other characters:
“<Esc>[
FormatCodem
”.
In Bash, the <Esc>
character can be obtained with the following syntaxes:
\e
\033
\x1B
Examples:
Code (Bash) | Preview |
---|---|
echo -e "\e[31mHello World\e[0m" | |
echo -e "\033[31mHello\e[0m World" |
NOTE¹: The -e
option of the echo
command enable the parsing of the escape sequences.
NOTE²: The “\e[0m
” sequence removes all attributes (formatting and colors). It can be a good idea to add it at the end of each colored text. ;)
NOTE³: The examples in this page are in Bash but the ANSI/VT100 escape sequences can be used in every programming languages.
Here are the most commonly supported control sequences for formatting text. Their support depends on the used terminal (see the compatibility list).
Code | Description | Example | Preview |
---|---|---|---|
1 | Bold/Bright | echo -e "Normal \e[1mBold" | |
2 | Dim | echo -e "Normal \e[2mDim" | |
4 | Underlined | echo -e "Normal \e[4mUnderlined" | |
5 | Blink 1) | echo -e "Normal \e[5mBlink" | |
7 | Reverse (invert the foreground and background colors) | echo -e "Normal \e[7minverted" | |
8 | Hidden (useful for passwords) | echo -e "Normal \e[8mHidden" |
Code | Description | Example | Preview |
---|---|---|---|
0 | Reset all attributes | echo -e "\e[0mNormal Text" | |
21 | Reset bold/bright | echo -e "Normal \e[1mBold \e[21mNormal" | |
22 | Reset dim | echo -e "Normal \e[2mDim \e[22mNormal" | |
24 | Reset underlined | echo -e "Normal \e[4mUnderlined \e[24mNormal" | |
25 | Reset blink | echo -e "Normal \e[5mBlink \e[25mNormal" | |
27 | Reset reverse | echo -e "Normal \e[7minverted \e[27mNormal" | |
28 | Reset hidden | echo -e "Normal \e[8mHidden \e[28mNormal" |
The following colors works with most terminals and terminals emulators 2), see the compatibility list for more informations.
NOTE: The colors can vary depending of the terminal configuration.
Code | Color | Example | Preview |
---|---|---|---|
39 | Default foreground color | echo -e "Default \e[39mDefault" | |
30 | Black | echo -e "Default \e[30mBlack" | |
31 | Red | echo -e "Default \e[31mRed" | |
32 | Green | echo -e "Default \e[32mGreen" | |
33 | Yellow | echo -e "Default \e[33mYellow" | |
34 | Blue | echo -e "Default \e[34mBlue" | |
35 | Magenta | echo -e "Default \e[35mMagenta" | |
36 | Cyan | echo -e "Default \e[36mCyan" | |
37 | Light gray | echo -e "Default \e[37mLight gray" | |
90 | Dark gray | echo -e "Default \e[90mDark gray" | |
91 | Light red | echo -e "Default \e[91mLight red" | |
92 | Light green | echo -e "Default \e[92mLight green" | |
93 | Light yellow | echo -e "Default \e[93mLight yellow" | |
94 | Light blue | echo -e "Default \e[94mLight blue" | |
95 | Light magenta | echo -e "Default \e[95mLight magenta" | |
96 | Light cyan | echo -e "Default \e[96mLight cyan" | |
97 | White | echo -e "Default \e[97mWhite" |
Code | Color | Example | Preview |
---|---|---|---|
49 | Default background color | echo -e "Default \e[49mDefault" | |
40 | Black | echo -e "Default \e[40mBlack" | |
41 | Red | echo -e "Default \e[41mRed" | |
42 | Green | echo -e "Default \e[42mGreen" | |
43 | Yellow | echo -e "Default \e[43mYellow" | |
44 | Blue | echo -e "Default \e[44mBlue" | |
45 | Magenta | echo -e "Default \e[45mMagenta" | |
46 | Cyan | echo -e "Default \e[46mCyan" | |
47 | Light gray | echo -e "Default \e[47mLight gray" | |
100 | Dark gray | echo -e "Default \e[100mDark gray" | |
101 | Light red | echo -e "Default \e[101mLight red" | |
102 | Light green | echo -e "Default \e[102mLight green" | |
103 | Light yellow | echo -e "Default \e[103mLight yellow" | |
104 | Light blue | echo -e "Default \e[104mLight blue" | |
105 | Light magenta | echo -e "Default \e[105mLight magenta" | |
106 | Light cyan | echo -e "Default \e[106mLight cyan" | |
107 | White | echo -e "Default \e[107mWhite" |
Some terminals (see the compatibility list) can support 88 or 256 colors. Here are the control sequences that permit you to use them.
NOTE¹: The colors number 256
is only supported by vte (GNOME Terminal, XFCE4 Terminal, Nautilus Terminal, Terminator,…).
NOTE²: The 88-colors terminals (like rxvt) does not have the same color map that the 256-colors terminals. For showing the 88-colors terminals color map, run the “256-colors.sh” script in a 88-colors terminal.
For using one of the 256 colors on the foreground (text color), the control sequence is
“<Esc>[38;5;
ColorNumberm
” where ColorNumber
is one of the following colors:
Examples:
Code (Bash) | Preview |
---|---|
echo -e "\e[38;5;82mHello \e[38;5;198mWorld" | |
for i in {16..21} {21..16} ; do echo -en "\e[38;5;${i}m#\e[0m" ; done ; echo |
For using one of the 256 colors on the background, the control sequence is
“<Esc>[48;5;
ColorNumberm
” where ColorNumber
is one of the following colors:
Examples:
Code (Bash) | Preview |
---|---|
echo -e "\e[40;38;5;82m Hello \e[30;48;5;82m World \e[0m" | |
for i in {16..21} {21..16} ; do echo -en "\e[48;5;${i}m \e[0m" ; done ; echo |
Terminals allow attribute combinations. The attributes must be separated by a semicolon (“;
”).
Examples:
Description | Code (Bash) | Preview |
---|---|---|
Bold + Underlined | echo -e "\e[1;4mBold and Underlined" | |
Bold + Red forground + Green background | echo -e "\e[1;31;42m Yes it is awful \e[0m" |
Terminal | Formatting | Colors | Comment | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Bold | Dim | Underlined | Blink | invert | Hidden | 8 | 16 | 88 | 256 | ||
aTerm | ok | - | ok | - | ok | - | ok | ~ | - | - | Lighter background instead of blink. |
Eterm | ~ | - | ok | - | ok | - | ok | ~ | - | ok | Lighter color instead of Bold. Lighter background instead of blink. Can overline a text with the “^[ [6m ” sequence. |
GNOME Terminal | ok | ok | ok | ok | ok | ok | ok | ok | - | ok | Strikeout with the “^[ [9m ” sequence. |
Guake | ok | ok | ok | ok | ok | ok | ok | ok | - | ok | Strikeout with the “^[ [9m ” sequence. |
Konsole | ok | - | ok | ok | ok | - | ok | ok | - | ok | |
Nautilus Terminal | ok | ok | ok | ok | ok | ok | ok | ok | - | ok | Strikeout with the “^[ [9m ” sequence. |
rxvt | ok | - | ok | ~ | ok | - | ok | ok | ok | - | If the background is not set to the default color, Blink make it lighter instead of blinking. Support of italic text with the “^[ [3m ” sequence. |
Terminator | ok | ok | ok | - | ok | ok | ok | ok | - | ok | Strikeout with the “^[ [9m ” sequence. |
Tilda | ok | - | ok | ok | ok | - | ok | ok | - | - | Underline instead of Dim. Convert 256-colors in 16-colors. |
XFCE4 Terminal | ok | ok | ok | ok | ok | ok | ok | ok | - | ok | Strikeout with the “^[ [9m ” sequence. |
XTerm | ok | - | ok | ok | ok | ok | ok | ok | - | ok | |
xvt | ok | - | ok | - | ok | - | - | - | - | - | |
Linux TTY | ok | - | - | - | ok | - | ok | ~ | - | - | Specials colors instead of Dim and Underlined. Lighter background instead of Blink, Bug with 88/256 colors. |
VTE Terminal 3) | ok | ok | ok | ok | ok | ok | ok | ok | - | ok | Strikeout with the “^[ [9m ” sequence. |
Notations used in the table:
ok
”: Supported by the terminal.~
”: Supported in a special way by the terminal.-
”: Not supported at all by the terminal.
The following shell script displays a lot of possible combination of the attributes (but not all, because it uses only one formatting attribute at a time).
#!/bin/bash # This program is free software. It comes without any warranty, to # the extent permitted by applicable law. You can redistribute it # and/or modify it under the terms of the Do What The Fuck You Want # To Public License, Version 2, as published by Sam Hocevar. See # http://sam.zoy.org/wtfpl/COPYING for more details. #Background for clbg in {40..47} {100..107} 49 ; do #Foreground for clfg in {30..37} {90..97} 39 ; do #Formatting for attr in 0 1 2 4 5 7 ; do #Print the result echo -en "\e[${attr};${clbg};${clfg}m ^[${attr};${clbg};${clfg}m \e[0m" done echo #Newline done done exit 0
The following script display the 256 colors available on some terminals and terminals emulators like XTerm and GNOME Terminal.
#!/bin/bash # This program is free software. It comes without any warranty, to # the extent permitted by applicable law. You can redistribute it # and/or modify it under the terms of the Do What The Fuck You Want # To Public License, Version 2, as published by Sam Hocevar. See # http://sam.zoy.org/wtfpl/COPYING for more details. for fgbg in 38 48 ; do # Foreground / Background for color in {0..255} ; do # Colors # Display the color printf "\e[${fgbg};5;%sm %3s \e[0m" $color $color # Display 6 colors per lines if [ $((($color + 1) % 6)) == 4 ] ; then echo # New line fi done echo # New line done exit 0
Discussion
if [[ ${EUID} == 0 ]] ; then
PS1='\e[1;31;48;5;234m\u \e[38;5;240mon \e[1;38;5;28;48;5;234m\h \e[38;5;54m\d \@\e[0m\n\e[0;31;48;5;234m[\w] \e[1m\$\e[0m '
else
PS1='\e[1;38;5;56;48;5;234m\u \e[38;5;240mon \e[1;38;5;28;48;5;234m\h \e[38;5;54m\d \@\e[0m\n\e[0;38;5;56;48;5;234m[\w] \e[1m\$\e[0m '
fi
@caravaggisto
pseudo graphic interface, draw good windows and all graphical controls in text mode. Only you need(for russians) use DOS866 encodding set. It containe full set of pseudo graphic symbols, others no. There is set of libraries of pseudo graphic controls. And you may easily make TUI(text user interface) API like GUI. But library is Turbo Vision for DOS 16 only. But this libs in source code available. If you want you may rewrite them for Linux platform. And if use 256 colors you get more better design nearest to GUI. Many years I try to find redy solution but failed. So if you want to do that you need to all work by yourself. But result will best. This API take tens times less resources and quicker then gui. They don't require GUI regime at all... It will be best
But API of all. There is only 1 restriction. You don't must draw pictures, graphics, videos and so on where you need pixel draw indeed. But there are little API like that. Most API don't need pixel draw at all.
I was actually looking to find out if there is a way to combine attributes {BOLD, Blink, etc} around the same subset of text in doing a bash echo command with the -e option.
Can you help with this matter?
\\War
You can combine attributes with a semicolon:
echo -e "\e[1;5m Bold+Blink \e[0m"
echo -e "\e[1;4;31m Bold+Underline+Red \e[0m"
Note that the blink attribute is supported only by few terminals (XTerm, tty).
Regards,
That worked splendidly! You are the man!
konrad@vps1 ~/web/abc▌▌▌mkdir xyz
PS1='\[\e[0m\]\[\e[48;5;236m\]\[\e[38;5;105m\]\u\[\e[38;5;105m\]@\[\e[38;5;105m\]\h\[\e[38;5;105m\] \[\e[38;5;221m\]\w\[\e[38;5;221m\]\[\e[38;5;105m\]\[\e[0m\]\[\e[38;5;236m\]\342\226\214\342\226\214\342\226\214\[\e[0m\]'
root:
PS1='\[\e[0m\]\[\e[48;5;236m\]\[\e[38;5;197m\]\u\[\e[38;5;197m\]@\[\e[38;5;197m\]\h\[\e[38;5;105m\] \[\e[38;5;221m\]\w\[\e[38;5;221m\]\[\e[38;5;105m\]\[\e[0m\]\[\e[38;5;236m\]\342\226\214\342\226\214\342\226\214\[\e[0m\]'
On xterm and Konsole, TAB moves the cursor, without touching the skipped-over positions (so the background color is unchanged), while Gnome Terminal appears to effectively write spaces (so the background color is changed). Your images show the latter, but note that is incompatible with xterm.
#Display the color
echo -en "\e[${fgbg};5;${color}m"
printf "%4d " ${color}
echo -en "\e[0m"
Also, the upper cbound should be 255, not 256:
for color in {0..255} ; do #Colors
\e
\033
\x1B
Can somebody explain for me?
Thank in advance.
This is only three ways to represent the same character. There will be no differences between using one representation or an other.
* \e is a convenient way provided by Bash to insert the Escape character.
* 33 is the position of the Escape character in the ASCII table expressed in octal (base 8, in decimal this is equal to 27)
* 1B is the position of the Escape character in the ASCII table expressed in hexadecimal (base 16)
→ So \0nn and \xNN are just a way to insert a character by providing its position in the ASCII table, in octal or hexadecimal format.
You can find an the ASCII table here → https://duckduckgo.com/?q=ascii+table&t=canonical
with that gradient,i was trying to work how to put text inside of it to get a gradient of of text but the text just repeats with the loop. how can i put this into a function something like gradient "some text" blue white or gradient "more text" blue white yellow, function gradient(){}?
for example:
echo -e "Normal \033[5mHello"
Normal Hello
##### It's normal print Normal Hello, Not blink.
Can you write truly blink text?
blink do not work on vte based terminals (most linux terminal, like gnome-terminal, tilda, guake, terminator, xfce4-terminal,...)
You can try with xterm, it should work on it.
See the compatibility table for more info: http://misc.flogisoft.com/bash/tip_colors_and_formatting?&#terminals_compatibility
\e[0m resets all colors and attributes.
\e[20m resets only attributes (underline, etc.), leaving colors unchanged.
\e[39m resets only foreground color, leaving attributes unchanged.
\e[49m resets only background color, leaving attributes unchanged.
\u: current username
\h: hostname up to the first ., \H: full hostname
\w: current working directory, \W: same, but only the basename
$(__git_ps1 "%s"): your current git branch if you're in a git directory, otherwise nothing
\$: if the effective UID is 0: #, otherwise $
\d: the date in "Weekday Month Date" format (e.g., "Tue May 26")
\t: the current time in 24-hour HH:MM:SS format, \T: same, but 12-hour format, \@: same, but in 12-hour am/pm format
\n: newline
\r: carriage return
\\: backslash
http://misc.flogisoft.com/bash/tip_customize_the_shell_prompt
PS: I translated the menu label from my french gnome-terminal. In yours, it can be slightly deferent.
would you please explain the control sequence of 8/16 Colors and 88/256 Colors
As I understand,
30 is for black text.
48 is for what?
5 is for blink which is not happening, not even in Xterm.
82 is background color.
please help.
In 8/16 color mode:
"3x" is for foreground color
"4x" is for background color
In 88/256 color mode:
"38;5" means "the next number is a foreground color in 88/256 color mode"
"48;5" means "the next number is a background color in 88/256 color mode"
so "38;5;XXX" and "48;5;XXX" allow you to select colors in 88/256 color mode.
In your example ("\e[30;48;5;82m"),
"30" is for back foreground (text in black)
"48;5;82" is for green background (in 88/256 color mode)
Thanx buddy.
keep rocking.
Cheers,
+ Joe
Example usage might so something like this:
if tput el; then
tput bce
else
# fill up manually with spaces
fi
In my shell script formating text (bold/colors) all works and the results look correct
if the output is sent to standard output. (Just calling the script ./myscript.sh
But, if i redirect the output into a file i only see original text including
statements such as ESC[90G ESC[1;32 and so on.
Any ideas?
1. Content of myscript.sh:
echo -e "OKAY TO BE PRINTED IN COLUMN 50 OF THIS LINE \e[20G OKAY"
2. ./myscript.sh &> output.txt 2>&1
3. Use Notepad++ to open output.txt: I see
OKAY TO BE PRINTED ON COLUMN 50 OF THIS LINE ESC[20G OKAY
If i use cat to show the content i see the correct results.
However, i want to see the same result in the text file as it is shown on default output.
do you know how can i make this formating to be kept in the file if i redirect the output of my shell script?
1. Content of my shell script "myscript.sh"
echo -e "PRINT RED HELLO AT COLUMN POSITION 80 \e[80G \e[91m HELLO"
2. ./myscript.sh &> output.txt
3. Content of output.txt:
PRINT RED HELLO AT COLUMN POSITION 80 ESC[80G ESC[91m HELLO
Many thanks for your support in advance.
Regards, Eddy
You cannot see the formating in your text editor, because it is your terminal emulator (XTerm, GNOME Terminal, Konsole,...) that generates colors when there is some special byte sequence in the output. Your text editor will just display the content of the file, it will not interpret it.
Regards,
Is there any way that I can display the color message on the terminal to the output file?
To be honnest it's basically the same but the output is a bit more... readable.
for fgbg in 38 48 ; do
i=0
for color in {0..15} ; do
if [ $i -lt 10 ] ; then
echo "\x1B[${fgbg};5;${color}m"' '${color}' '"\x1B[0m" | tr -d '\n'
else
echo "\x1B[${fgbg};5;${color}m"' '${color}' '"\x1B[0m" | tr -d '\n'
fi
i=$(($i+1))
if [ $((i % 8)) == 0 ] ; then
echo
fi
done
i=0
for color in {16..255} ; do
if [ $i -lt 84 ] ; then
echo "\x1B[${fgbg};5;${color}m"' '${color}' '"\x1B[0m" | tr -d '\n'
else
echo "\x1B[${fgbg};5;${color}m"' '${color}' '"\x1B[0m" | tr -d '\n'
fi
i=$(($i+1))
if [ $((i % 6)) == 0 ] ; then
echo
fi
done
echo
echo
done
exit 0
(sorry for the horrible indentation, no way to fix this unfortunately)
It is really informative and helpful, and a it's shame there is no formal document about this..
Also, just adding 22 as normal attribute code.
Last year I was bored in class learning the Windows terminal & Visual studio; I worked in hardware before I started studying, I made a chart for my classmates that translated what the code effectively was telling the 'pixels' what to do. So I made a wrapper that just turned 'bitswitches' on and off for each of the primary light colours and told them - 'Rather than trying to remember or have to look up what colour combinations output what, remember it as R.G.B. and a Power Intensity... if you want Bright Red, that's Full power, with Red Only... if you want a purple, it's Red and Blue for Magenta, and half power...If you know what the other two are, yellow and cyan, you won't need to remember 255 colours any more.'
The K in the chart represents 'Key' and the others on the HSB are dependent on how the manufacturer programmed in the logic circuit for high+ or low- voltage and the main circuit flag#.
http://i.imgur.com/YRNlKoZ.png
Soon after, the rest of the class were printing out rainbows for Hello World.
Text version of the chart: View it in monospace font, no tabs, just spaces.
## HARDWARE REFERENCE
DECIMAL 128 64 32 16 8 4 2 1
COLOR + BBF F- # K B G R
BINARY 0 0 1 1 0 1 0 1
HEX 3 5
FOREGROUND F F
BACKGROUND BB
## HARDWARE REFERENCE
DECIMAL 128 64 32 16 8 4 2 1
COLOR + BBF F- # K B G R
BINARY 1 0 0 1 0 0 0 1
HEX 9 1
FOREGROUND F F
BACKGROUND BB
My concern is , I have make 1 shell script which output come in colourful. So my requirement is I have save this output in .csv and i want when i fetch this .csv in local desktop output also come in colourful. Please help
For example, let's say (background) color 121, it's a light green. It is pretty close to "Pale Green" i.e. Red=152 Green=251 Blue=152 (or if you prefer hex, 98FB98). Is there somewhere I can look up the RGB values for 121, etc.?
So I'm trying to setup something that will use my prompt to change the colors, like this (works in bash, but not ksh):
PS1="\033[48;5;121m\033[34m\033[7m${LOGNAME}@${HOSTNAME}#\033[27m "
In my .profile, it will look up some information and set PS1 accordingly. For example, production servers would get one color of background, development servers another color. Linux servers get one color of foreground, Solaris another, etc. So, if I'm logged into a development Linux box, and I login from there into a production Solaris box, my colors will change - giving me a visual cue that I'm on a production server now, etc.
I have some other things that I want to use matching colors for, and I can define the colors using RGB. If I use color 121 for development, I'd need to know what RGB value that equates to so that I can use that same color to represent development on other things where I would define the color with RGB.
So is there are chart that shows these 256 colors and their RGB equivalents?
For the background color, the sequance is "\033[48;2;R;G;Bm" (e.g. "\033[48;2;255;64;0m Hello \033[0m")
For the foreground color, the sequance is "\033[38;2;R;G;Bm" (e.g. "\033[38;2;255;64;0m Hello \033[0m")
In xterm \e[21m does NOT perform reset of bold. According to docs (http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Functions-using-CSI-_-ordered-by-the-final-character_s_) \e[21m is "doubly underlined". To correctly reset either bold or dim to normal on xterm, one must actually use \e[22m. Which makes it pretty un-intuitive and pretty much the only way to find out is the hard way :-( Other terminals (at least VTE based ones), work just as described on this page.
no but seriously this was an insanely useful guide
if [ $((($color + 1) % 10)) == 0 ] ; then
... to the following one :
if [ $((($color + 1) % 6)) == 4 ] ; then
You'll have a better comprehension, and choosing the color will be easier for you.
Edit: updated! :)
https://gist.github.com/hypergig/ea6a60469ab4075b2310b56fa27bae55
yes, this works only when you print text in a terminal
PS1="\[\e[91m\]\u\[\e[38;5;208m\]@\[\e[92m\]\h:\[\e[96m\]\$PWD\[\e[35m\]//$(date +"%D-%H:%M" | sed 's/\//-/g')\n\[\e[38;5;21m\][$]~> \[\e[0m\] "
https://misc.flogisoft.com/_detail/bash/ico/tip_cursor_movements.png?id=bash%3Ahome ?
I need similar bash tips on cursor movement.
Thank you. :)
anyway, the main codes for moving the cursor are:
* echo -e "\e[1;1H" → moves the cursor to (1,1), that's the top left corner of the terminal (you can change the numbers to move somewhere else)
* echo -e "\e[2J" → Clear the terminal
Thanks for the update :)
{0..255} => $(seq 0 255)
$((($color + 1) % 6)) => $(( ($color + 1) % 6))
The "fixed" version is:
#!/bin/sh
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
for fgbg in 38 48 ; do # Foreground / Background
for color in $(seq 0 255) ; do # Colors
# Display the color
printf "\e[${fgbg};5;%sm %3s \e[0m" $color $color
# Display 6 colors per lines
if [ $(( ($color + 1) % 6)) == 4 ] ; then
echo # New line
fi
done
echo # New line
done
exit 0
#!/bin/sh
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
#Background
for clbg in $(seq 40 47) $(seq 100 107) 49 ; do
#Foreground
for clfg in $(seq 30 37) $(seq 90 97) 39 ; do
#Formatting
for attr in 0 1 2 4 5 7 ; do
#Print the result
printf "\e[${attr};${clbg};${clfg}m ^[${attr};${clbg};${clfg}m \e[0m"
done
echo #Newline
done
done
exit 0
However, I have a question about the 256 color table. I can see that there are colors with numbers from 0 to 256 which means, there actually are 257 colors (more that 8-bit) which made me wonder.
Then, I read your note:
"The colors number 256 is only supported by vte (GNOME Terminal, XFCE4 Terminal, Nautilus Terminal, Terminator,…)."
Do you mean the color with the number 256 or the amount of colors?
Thanks for the information and the quick reply!
for i in {16..21} {21..16} ; do echo -en "\e[38;5;${i}m#\e[0m" ; done ; echo
on fish shell?
for i in 21 27 33 39 45 51 50 49 48 47 46 82 118 154 190 226 220 214 208 202 196 197 198 199 200 201 165 129 93 57 21
do echo -en "\e[48;5;${i}m \e[0m"; done
Result: https://i.imgur.com/XEfjQN8.png
I use:
alias r='tput setab 1; tput el; tput cud1; tput sgr0; tput ed' # red line
alias g='tput setab 2; tput el; tput cud1; tput sgr0; tput ed' # green line
(I'm on Debian 9.9.0, gnome-terminal.)
Your web page is very nice! Excellent work! Thank you.
bold="\e[1m"
inv="\e[7"
red="\e[31m"
green="\e[32m"
yellow="\e[33m"
reset="\e[0m"
echo -ne "${yellow}${bold}Yellow Bold${reset}"
echo Normal
echo -ne ${red}${bold}Red Bold{reset}
echo -ne ${inv}${bold}Inversed{reset}
change echo by echo -ne
print("\033[032m grass is \033[0m
Also not limited to colors but works with mouse and keyboard interpretation (click move etc.).
wrote a lookup from ANSI 256 to RGB (decimal/hex) you may find it
interesting.
Feel free to hack it up and make use of it!
http://scriptsandoneliners.blogspot.com/2019/10/print-ansi-colors-in-rgb-hexdecimal.html