[Home] [Credit Search] [Category Browser] [Staff Roll Call] | The LINUX.COM Article Archive |
Originally Published: Tuesday, 31 October 2000 | Author: Mike Baker |
Published to: interact_articles_irc_recap/IRC Recap | Page: 1/1 - [Std View] |
Linux.com Best of IRC!
It's time for another edition of Best of IRC. As always we take an in-depth look at some of the questions asked on #Linuxhelp. If you haven't visited #Linuxhelp, you'll find instructions on getting there at the bottom of the Live! page; feel free to stop by and ask questions or possibly answer a few, as we appreciate any help we can get.
|
<ingenitor> how do you change the (blanking) screen-saver timeout (no x windows running, just the console)
<yath> setterm -blank 10 (guessing)
<[MbM]> ingenitor: man console_codes, seems to me it was ESC [ 9 ; n ]... meaning echo -e "\33[9;1]" sets it for one minute
<[MbM]> (\33 = esc)
<ingenitor> [MbM], thanx
<[MbM]> ingenitor: setterm does the same thing, i just find esc codes easier
<ingenitor> [MbM], i like esc codes... i'm used to ANSI from DOS anyways ;-)
How is it that the clear command actually clears the screen or colors are printed via ls?
It's a rarely known fact among users that the terminal actually reads and interprets specal codes called escape codes, named so because they start with the symbol for escape. Nearly every aspect of terminal control has an escape code associated with it although your favorite x terminal is likely to only support a small subset of those.
So what are the escape codes?
You'll find a pretty complete list of escape codes in the console_codes man
page (man console_codes.) The codes are written in the man page in the
following form:
ESC [ 9 ; n ] Set screen blank timeout to n minutes.
To use these escape codes you simply have to display them in the terminal; the easiest way to do that is using the echo command:
echo -e "\33[9;1]"
Note that ESC was replaced with \33 which is the expression for escape. You'll need to use the -e argument for echo so that it prints out the escape character and not "\33".
Do I need to use escape characters to do things?
No, there are other utilities like setterm which can control almost
the same settings. The difference is that with escape codes you can embed them
in places like like your bash prompt. A simple example would be to change the
bash prompt to display the current directory in your xterm titlebar:
export PS1="\h:\w\$ \[\033]2;\w\007\]"
For more information on escape codes read man console_codes and for information on setterm, man setterm