Have you ever wanted to use color int your output, but didn't know how? Well here's your chance.
These example should work in almost any *nix terminal system. Linux, Mac, etc
type this into your terminal:
echo "^[[0;32;40mThis is in color"
NOTE: the ^[ is actually a special escape character you get by pressing ctrl v + esc. If you write a program in C or something, the value of the character is 27, 0x1b, or \033 if you want to embed it.
also, the quote marks are necessary for this to work
That should be in green, and on my computer the green carries through to every following line. If you want to not be working in terminal with green text, what you can do is type this:
and that should reset your terminal colors back to normal.
The anatomy of this is ^[[ attribute; foreground; backgroundm
The attributes are:
0 - reset everything
1 - bright (bold)
2 - dim
3 - underline (didn't for me, but some worked for some)
4 - underline (worked for me)
5 - blink
6 - nothing
7 - reverse (color scheme, not the text)
8 - hidden
The foreground colors are:
30 - black
31 - red
32 - green
33 - yellow
34 - blue
35 - magenta
36 - cyan
37 - white
and the background colors are the same as the foreground colors + 10
black - 40, etc
So, if you want to have cyan blinking text on a magnta background, you would use this:
and because that is very ugly, let's go back to the default: echo "^[[0;;m"
What can you do with this? I don't know, have fun.
The first thing I did was set my terminal prompt string to be green.
export PS1="^[[0;32;40m\h:\W \u ^[[0;;m\$ "
if you want to make that permanent,
echo "export PS1=\"^[[0;32;40m\h:\W \u ^[[0;;m\$ \"" >> .bashrc
should do the trick.
\h - host name
\W - present working directory
\w - full path of PWD
\u - user name
Page 1 of 1
Colored output on the console without curses
Replies To: Colored output on the console
Page 1 of 1