Problem
How do I change my default screen command prompt from "$" or "#" to one with color?
Solution
As an example only:The example system name is "scotest", I want to change the prompt
to show "scotest...>>" in color. First, create a file called
"/prompt.txt" which contains:For SCO OpenServer 5:^[[1;37;46m scotest...>>^[[1;37;40mThis will print the name in cyan, alter the "46" for others. Use "^[[0" for low intensity mode.
For SCO UnixWare 2 and UnixWare 7:
^[[=0F^[[=3G^[[0m scotest...>>^[[=7F^[[=0G^[[0m^[[JSet the permissions:# chmod 666 /prompt.txtThe characters in the file cannot simply be typed in as they appear in the examples above, so:
^[[=0F^[[=3G^[[0m scotest...>>^[[=7F^[[=0G^[[0m^[[Jcannot be typed as:i for insert, then ^, then [, then [, then =, etc. etc.
it must be:i for insert, Control + V, then Escape (this puts in "^["), then [, then =, then 0, then F, then Escape, then a for append, then Control + V, then Escape, then =, etc. etc.
Rather than type the above, the codes can be set via octal (see the man page for "ascii" for conversion tables). Create a file called "octal.sh" which contains (this should all be one line):
echo "\033\0133\061\007337\007346\0155 scotest...>>
\033\0133\061\007337\007340\0155" >prompt.txtMake the file executable with "# chmod 755 octal.sh". Then run it as:
# ./octal.shThis will create the SCO OpenServer 5 prompt file as above.
The escape codes to activate and deactivate the colors can be seen using the "setcolor" command on all the operating systems. Run the command and direct the output to a file, for example:
# setcolor >test1Then use "vi" to look at the file and examine what numbers are required for what color.
To test, simply cat the file to the screen:
# cat /prompt.txtCodes can also be checked by using the Escape key and then typing the remainder of the code (it might not be visible on screen) to see its effects. This might not work with all systems.
To activate the new prompt when a user logs in, edit the system "/etc/profile" file and add these lines to the end of the file:
...
...
PS1=`cat /prompt.txt`
export PS1The system could be set up, for example, to make one console multiscreen show a prompt in red, for example, and then others in blue, or could print the process id of the shell or other information.
The "/etc/profile" file could look like:...
if [ tty = /dev/tty01 -o tty = /dev/tty02 ]
then
PS1=`cat /prompt.txt`
else
PS1=`tty`-$$
fi
export PS1NOTE: The above only works on character multiscreens and scoterms on OpenServer 5, and only character screens UnixWare. It does not work on redirected scoterms or dtterms on UnixWare.
See also
setcolor(1), setcolor(C), uname(C), tty(C), vi(C), ascii(M).