Skip to main content
Welcome guest. | Register | Login | Post

Terminal colours

5 replies [Last post]
AndrewB's picture
Offline
Joined: 2005-12-18

Hey all, I have been wondering of late (been playing with Frame Buffers and such with no X) and stumbled accross something I dont know of.
How would you make a virtial terminal display the text in a different colour?
And wherre can I set this so it defaults?

supermike's picture
Offline
Joined: 2006-02-17

Look up VT100 or VT220 codes. Most terminals support these ASCII codes and they usually begin with an ESC character 0x027 followed by another character like "K", "c", etc. Given the right combo, you can turn on coloring. I have done a bit of this about 2 years ago, but don't recall everything unless I look back over my notes. You can also use these codes to do funky things on the screen, such as move the cursor, draw special drawing characters, simulate menus, create special scroll regions, etc.

To turn it on by default. Hmm. There's probably a dot file like .bashrc, etc., or perhaps a variable you edit, to turn this on by default. BTW, do a man on termcap.

libervisco's picture
Offline
Joined: 2006-05-04

This might help: CLI Magic: Colorize your prompt. Also this shows some cool examples as well as links to pages with code you put in .bashrc to make it permanent: Bash Prompts

If you just want to enable colors in console (even with no X) I think that you just need to edit your /etc/rc.conf so that the USECOLOR option says yes, like this:

USECOLOR="yes"

If you don't have /etc/rc.conf you must have a differently named configuration file as well as in a different location. I think that on debian based distros it is in /etc/init.d/rc.conf or something like that.

It shouldn't be hard to find it.

Offline
Joined: 2005-12-20

Documentation/VGA-softcursor.txt in your kernel tree might prove an interesting read.

tbuitenh's picture
Offline
Joined: 2005-12-21
"libervisco" wrote:

If you just want to enable colors in console (even with no X) I think that you just need to edit your /etc/rc.conf so that the USECOLOR option says yes, like this:

USECOLOR="yes"

If you don't have /etc/rc.conf you must have a differently named configuration file as well as in a different location. I think that on debian based distros it is in /etc/init.d/rc.conf or something like that.

It doesn't work that way on most linux distributions, only on arch and maybe a few others (slackware?). Anyway the USECOLOR option on arch only enables coloring of rc script messages (so the word "fail" will be red). Colors are always enabled unless you use a monochrome monitor.

tbuitenh's picture
Offline
Joined: 2005-12-21

If you like a practical joke, hide these two scripts somewhere on the computer of a coworker and start both of them in the background (&) from their .bashrc . They will love it.

#!/bin/bash
while true; do
  for B in `seq 34 37`; do
    echo -n -e \\e["$B"m
    sleep 2
  done
done
#!/bin/bash
while true; do
  for B in `seq 40 43`; do
    echo -n -e \\e["$B"m
    sleep 1
  done
done

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.